List of usage examples for org.apache.commons.lang StringUtils isBlank
public static boolean isBlank(String str)
Checks if a String is whitespace, empty ("") or null.
From source file:com.enonic.cms.business.core.security.userstore.connector.remote.plugin.RemoteUserStoreFactory.java
public RemoteUserStorePlugin create(String type, Properties props) { RemoteUserStorePlugin userStorePlugin = createInstance(type); if (props != null) { BeanMap bean = new BeanMap(userStorePlugin); for (Object key : props.keySet()) { String strKey = key.toString(); String strValue = props.getProperty(strKey); // Preventing this property to be set as false if it blank (since it will be confusing for the user) if ("readUserSyncAttributeAsBinary".equals(strKey) && StringUtils.isBlank(strValue)) { continue; }/*from w w w . j a v a 2s. c om*/ try { bean.put(strKey, strValue); } catch (Exception e) { LOG.warn("Failed to set property [" + strKey + "] with value [" + strValue + "]."); } } } return userStorePlugin; }
From source file:name.chengchao.myhttpclient.version3_1.HttpClient3UtilUseManager.java
/** * ?url?ResponseBody,method=get//from w ww . j av a 2s . com * * @param url exp:http://192.168.1.1:8080/dir/target.html * @return byte[]? */ public static byte[] getDataFromUrl(String url, int timeout) { if (StringUtils.isBlank(url)) { logger.error("url is blank!"); return null; } HttpClient httpClient = new HttpClient(connectionManager); // httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(8000); // ? httpClient.getParams().setSoTimeout(timeout); GetMethod method = new GetMethod(url); // fix??? // method.setRequestHeader("Connection", "close"); // ??1 method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(1, false)); try { int statusCode = httpClient.executeMethod(method); if (statusCode == HttpStatus.SC_OK) { return method.getResponseBody(); } else { throw new RuntimeException("http request error,return code:" + statusCode + ",msg:" + new String(method.getResponseBody())); } } catch (HttpException e) { method.abort(); logger.error(e.getMessage()); } catch (IOException e) { method.abort(); logger.error(e.getMessage()); } finally { // Release the connection. method.releaseConnection(); } return null; }
From source file:com.enonic.cms.core.content.contentdata.custom.stringbased.TextDataEntry.java
public boolean breaksRequiredContract() { return StringUtils.isBlank(value); }
From source file:com.likethecolor.alchemy.api.parser.json.TitleParser.java
@Override protected void populateResponse(Response<TitleAlchemyEntity> response) { final JSONObject jsonObject = getJSONObject(); final String title = getString(JSONConstants.TITLE_KEY, jsonObject); if (!StringUtils.isBlank(title)) { response.addEntity(new TitleAlchemyEntity(title)); }//from w w w. j a va2 s. c om }
From source file:co.freeside.betamax.message.AbstractMessage.java
public String getContentType() { String contentTypeHeader = getHeader(CONTENT_TYPE); if (!StringUtils.isBlank(contentTypeHeader)) { return StringUtils.substringBefore(contentTypeHeader, ";"); } else {//from ww w .ja va 2 s. c o m return DEFAULT_CONTENT_TYPE; } }
From source file:com.likethecolor.alchemy.api.parser.json.AuthorParser.java
@Override protected void populateResponse(Response<AuthorAlchemyEntity> response) { final JSONObject jsonObject = getJSONObject(); final String author = getString(JSONConstants.AUTHOR_KEY, jsonObject); if (!StringUtils.isBlank(author)) { final AuthorAlchemyEntity entity = new AuthorAlchemyEntity(author); response.addEntity(entity);//from w w w.j a va 2s . com } }
From source file:edu.harvard.iq.dataverse.DatasetFieldValidator.java
@Override public boolean isValid(DatasetField value, ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); // we do this so we can have different messages depending on the different issue DatasetFieldType dsfType = value.getDatasetFieldType(); //SEK Additional logic turns off validation for templates if (isTemplateDatasetField(value)) { return true; }//from ww w . j a va2s. c o m if (((dsfType.isPrimitive() && dsfType.isRequired()) || (dsfType.isPrimitive() && value.isRequired())) && StringUtils.isBlank(value.getValue())) { try { context.buildConstraintViolationWithTemplate(dsfType.getDisplayName() + " is required.") .addConstraintViolation(); } catch (NullPointerException npe) { //if there's no context for the error we can't put it anywhere.... } return false; } return true; }
From source file:com.alibaba.jstorm.ui.NimbusClientManager.java
public static NimbusClient getNimbusClient(String clusterName) throws Exception { Map conf = UIUtils.readUiConfig(); if (DEFAULT.equals(clusterName)) { // do nothing } else if (StringUtils.isBlank(clusterName) == false) { UIUtils.getClusterInfoByName(conf, clusterName); }//from w w w . j a va 2 s.c om return NimbusClient.getConfiguredClient(conf); }
From source file:com.baidu.rigel.biplatform.ac.util.PlaceHolderUtils.java
/** * ???KEY?? ${abc}/* w w w.j a va 2 s . com*/ * <p> * ?????^\\$\\{[^\\}]+\\}$ * </p> * * @param placeHolder ?? * @return ????KEY */ public static String getKeyFromPlaceHolder(String placeHolder) { if (StringUtils.isBlank(placeHolder)) { throw new IllegalArgumentException("can not get key from empty placeHolder"); } if (!Pattern.matches("^\\$\\{[^\\}]+\\}$", placeHolder)) { return placeHolder; } else { return placeHolder.substring(2, placeHolder.length() - 1); } }
From source file:com.haulmont.cuba.client.sys.config.EntityFactory.java
@Override public Object build(String string) { if (StringUtils.isBlank(string)) return null; EntityLoadInfo info = EntityLoadInfo.parse(string); if (info == null) throw new IllegalArgumentException("Invalid entity info: " + string); LoadContext ctx = new LoadContext(info.getMetaClass()).setId(info.getId()); if (info.getViewName() != null) ctx.setView(info.getViewName()); return ds.load(ctx); }