Example usage for org.apache.commons.lang StringUtils isNotBlank

List of usage examples for org.apache.commons.lang StringUtils isNotBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils isNotBlank.

Prototype

public static boolean isNotBlank(String str) 

Source Link

Document

Checks if a String is not empty (""), not null and not whitespace only.

Usage

From source file:com.intuit.tank.harness.functions.JexlDateFunctions.java

/**
 * Get the current date.//from   w w  w  .j  ava 2  s.c  o m
 * 
 * @param format
 *            The format of the response (MM-dd-yyyy, MMddyyyy, etc)
 * @param timezone
 *            the timeZone that the date should be formatted in.
 * 
 * @return The current date
 */
public String currentDate(String format, String timezone) {
    DateFormat formatter = getFormatter(format);
    if (StringUtils.isNotBlank(timezone)) {
        formatter.setTimeZone(TimeZone.getTimeZone(timezone));
    }
    return formatter.format(new Date());
}

From source file:com.doculibre.constellio.wicket.panels.results.IntelliGIDSearchResultPanel.java

public IntelliGIDSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id, doc, dataProvider);

    String contentLength = (String) doc.getFieldValue("contentLength");
    String type = (String) doc.getFieldValue("subType");

    String contentLengthKBStr;//from ww w  .ja v  a  2  s  .c om
    if (StringUtils.isNotBlank(contentLength)) {
        long contentLengthBytes;
        try {
            contentLengthBytes = Long.valueOf(contentLength);
        } catch (NumberFormatException e) {
            contentLengthBytes = -1;
        }
        double contentLengthKB = (double) contentLengthBytes / 1000;
        DecimalFormat contentLengthKBFormatter = new DecimalFormat();
        contentLengthKBFormatter.setMinimumFractionDigits(0);
        contentLengthKBFormatter.setMaximumFractionDigits(0);
        contentLengthKBStr = contentLengthKBFormatter.format(contentLengthKB);
        if ("0".equals(contentLengthKBStr)) {
            contentLengthKBStr = null;
        }
    } else {
        contentLengthKBStr = null;
    }

    add(new Label("contentLength", contentLengthKBStr + " KB").setVisible(contentLengthKBStr != null));
    add(new Label("type", type).setVisible(StringUtils.isNotBlank(type)));

}

From source file:com.acc.filter.FilterSpringUtil.java

/**
 * The same as {@link #getSpringBean(HttpServletRequest, String, Class)} but uses ServletContext as the first
 * parameter. It might be used in places, where HttpServletRequest is not available, but ServletContext is.
 *///  w  ww  . j ava  2 s  . c  o  m
public static <T> T getSpringBean(final ServletContext servletContext, final String beanName,
        final Class<T> beanClass) {
    T ret = null;
    final WebApplicationContext appContext = WebApplicationContextUtils
            .getRequiredWebApplicationContext(servletContext);

    if (StringUtils.isNotBlank(beanName)) {
        try {
            ret = (T) appContext.getBean(beanName);
        } catch (final NoSuchBeanDefinitionException nsbde) {
            LOG.warn("No bean found with the specified name. Trying to resolve bean using type...");
        }
    }
    if (ret == null) {
        if (beanClass == null) {
            LOG.warn("No bean could be resolved. Reason: No type specified.");
        } else {
            final Map<String, T> beansOfType = appContext.getBeansOfType(beanClass);
            if (beansOfType != null && !beansOfType.isEmpty()) {
                if (beansOfType.size() > 1) {
                    LOG.warn("More than one matching bean found of type " + beanClass.getSimpleName()
                            + ". Returning the first one found.");
                }
                ret = beansOfType.values().iterator().next();
            }
        }
    }
    return ret;
}

From source file:com.jsmartframework.web.util.WebImage.java

public void init(ServletContext servletContext) {
    if (contextPath == null) {
        contextPath = "";
        String assetsUrl = CONFIG.getContent().getAssetsUrl();

        if (StringUtils.isNotBlank(assetsUrl)) {
            contextPath = assetsUrl.endsWith("/") ? assetsUrl.substring(0, assetsUrl.length() - 1) : assetsUrl;
        } else if (StringUtils.isNotBlank(servletContext.getContextPath())) {
            contextPath = servletContext.getContextPath();
        }/*w ww  . java 2  s .  co m*/
    }
}

From source file:com.janrain.backplane.server.config.BusConfig.java

public EnumSet<BackplaneConfig.BUS_PERMISSION> getPermissions(String user) {
    if (isBusConfigField(user)) {
        throw new IllegalArgumentException("Invalid user name: " + user);
    }// w w  w . jav a 2s  . co  m

    String perms = get(user);
    EnumSet<BackplaneConfig.BUS_PERMISSION> result = EnumSet.noneOf(BackplaneConfig.BUS_PERMISSION.class);
    if (StringUtils.isNotBlank(perms)) {
        for (String perm : perms.split(",")) {
            result.add(BackplaneConfig.BUS_PERMISSION.valueOf(perm));
        }
    }
    return result;
}

From source file:net.di2e.ecdr.search.transform.atom.security.impl.XmlMetadataSecurityMarkingHandler.java

@Override
public SecurityData getSecurityData(Metacard metacard) {
    String metadata = metacard.getMetadata();
    if (StringUtils.isNotBlank(metadata)) {
        XPathHelper helper = new XPathHelper(metacard.getMetadata());
        Document document = helper.getDocument();
        NodeList nodeList = document.getElementsByTagNameNS("*", "security");
        if (nodeList != null && nodeList.getLength() > 0) {
            Element element = (Element) nodeList.item(0);
            NamedNodeMap nodeNameMap = element.getAttributes();
            int length = nodeNameMap.getLength();

            Map<String, List<String>> securityProps = new HashMap<String, List<String>>();
            String securityNamespace = null;
            for (int i = 0; i < length; i++) {
                Attr attr = (Attr) nodeNameMap.item(i);
                String value = attr.getValue();
                if (!attr.getName().startsWith(XMLNS_PREFIX) && StringUtils.isNotBlank(value)) {
                    securityProps.put(attr.getLocalName(), SecurityMarkingParser.getValues(value));
                    if (securityNamespace == null) {
                        securityNamespace = attr.getNamespaceURI();
                    }/*from ww w  .java2s  . co m*/
                }
            }
            if (!securityProps.isEmpty()) {
                return new SecurityDataImpl(securityProps, securityNamespace);
            }
        }
    }
    return null;
}

From source file:gobblin.hive.HiveMetaStoreClientFactory.java

private static HiveConf getHiveConf(Optional<String> hcatURI) {
    HiveConf hiveConf = new HiveConf();
    if (hcatURI.isPresent() && StringUtils.isNotBlank(hcatURI.get())) {
        hiveConf.setVar(HiveConf.ConfVars.METASTOREURIS, hcatURI.get());
        hiveConf.set(HIVE_METASTORE_TOKEN_SIGNATURE, hcatURI.get());
    }//w  ww  . ja  v  a  2  s.  com
    return hiveConf;
}

From source file:com.hp.autonomy.aci.content.identifier.reference.Reference.java

/**
 * Creates a new {@code Reference} instance for the specified string reference and section number.
 *
 * @param reference The document reference
 * @param section The section number/*from w w w .  j a v a2s.c  o  m*/
 */
public Reference(final String reference, final int section) {
    Validate.isTrue(StringUtils.isNotBlank(reference), "Reference must not be blank");
    Validate.isTrue(section >= 0, "Section number must not be less than zero");

    this.reference = reference;
    this.section = section;
}

From source file:com.thinkbiganalytics.integration.SshConfig.java

@PostConstruct
public void initIt() throws Exception {
    LOG.info(new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("host", host)
            .append("port", port).append("username", username)
            .append("password", StringUtils.isNotBlank(password) ? "removed" : "not provided")
            .append("keyfile", keyfile).append("known-hosts", knownHosts).toString());

    if (StringUtils.isNotBlank(password) && StringUtils.isNotBlank(keyfile)) {
        throw new IllegalStateException(
                "Must not set both keyfile and password at the same time. Set one or the other.");
    }/*from ww w . ja  v  a  2 s  .c o m*/
    if (StringUtils.isBlank(password) && StringUtils.isBlank(keyfile)) {
        throw new IllegalStateException("Must provide either a keyfile or a password.");
    }
}

From source file:com.ultrapower.eoms.common.plugin.ecside.view.html.ColumnBuilder.java

    public void cellEdit(){
       String cellValue=column.getPropertyValueAsString();
   /*from   w ww .j a va2 s .c o m*/
      if (StringUtils.isNotBlank(cellValue)){
          html.append(" cellValue=\"").append(cellValue.replaceAll("\"","\\\"")).append("\" ");
      }

//      
      html.attribute(column.getEditEvent(), ECSideConstants.UTIL_FUNCTION_NAME+".editCell(this,'"+column.getModel().getTable().getTableId()+"')");

       
//      if (StringUtils.isNotBlank(cellName)){
//         html.append(" cellName=\"").append(cellName).append("\" ");
//      }
       
    }