List of usage examples for org.apache.commons.lang3 StringUtils isEmpty
public static boolean isEmpty(final CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0.
From source file:cn.vlabs.clb.server.ui.frameservice.URLBuilder.java
public static String getTrivialURL(String storageKey) { if (StringUtils.isEmpty(storageKey)) return null; return NGX_DOMAIN + "/" + TRIVIAL_CTX + "/" + storageKey; }
From source file:com.intbit.util.ServletUtil.java
public static boolean mapContainsKey(Map<String, Object> requestBodyMap, String key) { if (!requestBodyMap.containsKey(key) || requestBodyMap.get(key) == null || StringUtils.isEmpty(requestBodyMap.get(key).toString())) { return false; }//from w w w . ja va2 s .c om return true; }
From source file:com.tethrnet.manage.db.AuthDB.java
/** * auth user and return auth token if valid auth * * @param auth username and password object * @return auth token if success//from w w w .j a v a2 s . c om */ public static String login(Auth auth) { String authToken = null; //admin just for locally if (!auth.getUsername().equals("admin")) { //check ldap first authToken = ExternalAuthUtil.login(auth); } if (StringUtils.isEmpty(authToken)) { Connection con = null; try { con = DBUtils.getConn(); //get salt for user String salt = getSaltByUsername(con, auth.getUsername()); //login PreparedStatement stmt = con .prepareStatement("select * from users where enabled=true and username=? and password=?"); stmt.setString(1, auth.getUsername()); stmt.setString(2, EncryptionUtil.hash(auth.getPassword() + salt)); ResultSet rs = stmt.executeQuery(); if (rs.next()) { auth.setId(rs.getLong("id")); authToken = UUID.randomUUID().toString(); auth.setAuthToken(authToken); auth.setAuthType(Auth.AUTH_BASIC); updateLogin(con, auth); } DBUtils.closeRs(rs); DBUtils.closeStmt(stmt); } catch (Exception e) { log.error(e.toString(), e); } DBUtils.closeConn(con); } return authToken; }
From source file:de.micromata.genome.gwiki.controls.GWikiPageNotFound.java
public Object onInit() { if (StringUtils.isEmpty(getPageId()) == true) { setPageId((String) wikiContext.getRequestAttribute("NotFoundPageId")); }/* ww w. j a v a 2 s . c o m*/ if (StringUtils.isNotEmpty(getPageId()) == true) { if (wikiContext.getWikiWeb().getAuthorization().isAllowTo(wikiContext, GWikiAuthorizationRights.GWIKI_CREATEPAGES.name()) == true) { allowCreatePage = true; } } return null; }
From source file:com.haulmont.cuba.web.gui.components.converters.SimpleStringToIntegerConverter.java
@Override public Integer convertToModel(String value, Class<? extends Integer> targetType, Locale locale) throws ConversionException { if (StringUtils.isEmpty(value)) { return null; }// ww w . j a va 2 s . c o m try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConversionException(e); } }
From source file:com.addthis.hydra.job.spawn.jersey.DefaultAuthenticator.java
@Override public Optional<User> authenticate(BasicCredentials credentials) throws AuthenticationException { if (!StringUtils.isEmpty(credentials.getUsername())) { return Optional.of(new User(credentials.getUsername(), credentials.getUsername(), true)); //default admin }/*from www .j av a 2 s .c om*/ return Optional.absent(); }
From source file:com.salesforce.ide.apex.internal.core.tooling.systemcompletions.model.Constructor.java
@Override public String getReplacementString() { if (StringUtils.isEmpty(name)) return null; StringBuilder sb = new StringBuilder(); sb.append(name);// w ww . j ava 2 s. c o m sb.append("()"); return sb.toString(); }
From source file:com.cisco.oss.foundation.logging.appender.EmptyMessageFilter.java
@Override public int decide(LoggingEvent event) { if (event.getMessage() instanceof String) { if (StringUtils.isEmpty((String) event.getMessage())) { return Filter.DENY; }/*from w w w. j a v a2 s .c o m*/ } return Filter.NEUTRAL; }
From source file:com.baasbox.service.user.FriendShipService.java
private static String getWhereFromCriteria(QueryParams criteria) { String where = WHERE_FRIENDS; if (!StringUtils.isEmpty(criteria.getWhere())) where += " and (" + criteria.getWhere() + ")"; return where; }
From source file:io.fabric8.che.starter.template.CheServerTemplateTest.java
@Test public void processTemplate() throws MalformedURLException, IOException { String json = template.get(); assertTrue(!StringUtils.isEmpty(json)); ObjectMapper mapper = new ObjectMapper(); JsonNode node = mapper.readTree(json); assertTrue(node.getNodeType() == JsonNodeType.OBJECT); }