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

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

Introduction

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

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:com.cognifide.cq.cqsm.core.scripts.ScriptUtils.java

public static boolean isAction(String line) {
    return !(StringUtils.isBlank(line) || ScriptUtils.isComment(line));
}

From source file:com.edm.app.auth.Auth.java

public static void robot(String robotPath) {
    BufferedReader reader = null;
    try {/*  w w w .  j a v  a 2  s  .co  m*/
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(robotPath), "UTF-8"));
        String line = null;

        while ((line = reader.readLine()) != null) {
            if (StringUtils.isBlank(line)) {
                continue;
            }
            String key = StringUtils.substringBefore(line, "=");
            String val = StringUtils.substringAfter(line, "=");
            boolean r = StringUtils.equals(md5.encode(StringUtils.upperCase(key)),
                    "cebb21b542877339c40e7e8ecc96796e");
            if (StringUtils.isNotBlank(key) && r) {
                if (StringUtils.isNotBlank(val)) {
                    ROBOT = StringUtils.lowerCase(val);
                    break;
                }
            }
        }
    } catch (Exception e) {
        logger.error("(Auth:robot) error: ", e);
    } finally {
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (IOException e) {
        }
    }
}

From source file:com.meltmedia.cadmium.email.jersey.EmailFormValidator.java

public static void validate(MultivaluedMap<String, String> formData, EmailComponentConfiguration config,
        ContentService contentService) throws ValidationException {

    List<ValidationError> errors = new ArrayList<ValidationError>();

    // Validate From Name
    if (StringUtils.isBlank(getRequiredFieldValue(formData, config.getFromName(), Constants.FROM_NAME))) {
        errors.add(new ValidationError(Constants.FROM_NAME, Constants.FROM_NAME + " is required."));
    }/*ww w . j  a  v  a 2  s  . c  o  m*/

    // Validate ToAddress
    String toAddress = getRequiredFieldValue(formData, config.getToAddress(), Constants.TO_ADDRESS);
    if (StringUtils.isBlank(toAddress)) {
        errors.add(new ValidationError(Constants.TO_ADDRESS, Constants.TO_ADDRESS + " is required."));
    } else if (!isValidEmailAddress(toAddress)) {
        errors.add(new ValidationError(Constants.TO_ADDRESS,
                Constants.TO_ADDRESS + " is an invalid email address."));
    }

    //  Validate To Name
    if (StringUtils.isBlank(getRequiredFieldValue(formData, config.getToName(), Constants.TO_NAME))) {
        errors.add(new ValidationError(Constants.TO_NAME, Constants.TO_NAME + " is required."));
    }

    // Validate Subject
    if (StringUtils.isBlank(getRequiredFieldValue(formData, config.getSubject(), Constants.SUBJECT))) {
        errors.add(new ValidationError(Constants.SUBJECT, Constants.SUBJECT + " is required."));
    }
    for (Field field : config.getFields()) {
        checkValidField(field, formData, contentService, errors);
    }

    if (errors.size() > 0) {
        throw new ValidationException("Validation error(s) occurred.",
                errors.toArray(new ValidationError[errors.size()]));
    }

}

From source file:com.autentia.wuija.trace.persistence.OperationalTraceBuilder.java

public static OperationalTrace generateOperationalTrace(String userName, OperationalTraceTypeEnum type,
        String string1, String string2) {
    if (StringUtils.isBlank(userName)) {
        throw new IllegalArgumentException("username can not be empty or null");
    }//from   w  w w . j a  va 2s .co  m

    if (type == null) {
        throw new IllegalArgumentException("type can not be null");
    }

    return new OperationalTrace(userName, type, string1, string2 == null ? "" : string2);
}

From source file:com.taobao.adfs.database.tdhsocket.client.util.ConvertUtil.java

public static boolean getBooleanFromString(String v) {
    if (StringUtils.isBlank(v)) {
        return false;
    }//from  w w  w .j a  v a2  s. c o  m
    int c = Character.toLowerCase(v.charAt(0));
    return !(c == 'f' || c == 'n' || c == '0');
}

From source file:com.aqnote.shared.cryptology.cert.util.KeyStoreFileUtil.java

public static void writePkcsFile(String b64P12, String p12fileName) throws IOException {

    if (StringUtils.isBlank(p12fileName) || StringUtils.isBlank(b64P12)) {
        return;/*from  ww  w .  j  av a 2  s . c  o m*/
    }
    byte[] p12File = Base64.decodeBase64(b64P12);
    FileOutputStream fos = new FileOutputStream(p12fileName);
    fos.write(p12File);
    fos.flush();
    fos.close();
}

From source file:com.zxy.commons.codec.utils.Base64Utils.java

/**
 * ?//from   w w  w.  ja  v  a  2 s.c  o  m
 * 
 * @param source ??
 * @param charset 
 * @return ??
 */
public static String encode(String source, String charset) {
    if (StringUtils.isBlank(source)) {
        return null;
    }
    return new String(Base64.encodeBase64(source.getBytes(Charset.forName(charset))));
}

From source file:com.zxy.commons.codec.utils.MD5Utils.java

/**
 * 32?md5?//from   ww w .j a  va  2 s . c o  m
 * 
 * @param source source
 * @return 32?md5?
*/
public static String encode32(String source) {
    if (StringUtils.isBlank(source)) {
        return source;
    }
    return Hashing.md5().hashBytes(source.getBytes()).toString();
}

From source file:gov.nih.nci.cabig.caaers.domain.DateValue.java

/**
 * String to date value.//from   w w  w.j a v  a  2 s  . co m
 *
 * @param date the date
 * @return the date value
 * @throws ParseException the parse exception
 */
public static DateValue stringToDateValue(String date) throws ParseException {
    if (StringUtils.isBlank(date)) {
        return null;
    }
    String[] dateParts = date.split("/");
    int size = dateParts.length;
    if (size != 3)
        throw new ParseException("Unknown format, expected format is 'mm/dd/yyyy'", 0);
    DateValue dateValue = new DateValue();
    try {
        dateValue.setMonth(Integer.parseInt(dateParts[0]));
        dateValue.setDay(Integer.parseInt(dateParts[1]));
        dateValue.setYear(Integer.parseInt(dateParts[2]));
    } catch (NumberFormatException e) {
        throw new ParseException(
                "Unknown format, unable to parse the date values, expected format is 'mm/dd/yyyy'", 0);
    }
    return dateValue;
}

From source file:com.taobao.top.common.server.RefundMessageUrlKit.java

public static String perform(String prefixUrl, String dbUrl) {
    if (StringUtils.isNotEmpty(dbUrl) && dbUrl.length() > 2) {
        if (StringUtils.isBlank(prefixUrl)) {
            prefixUrl = DEFAULT_ONLINE_PICTURL;
        }/*from w  ww .  jav  a  2  s  .  c  o m*/
        if (!prefixUrl.startsWith(preFix_http)) {
            prefixUrl = preFix_http + prefixUrl;
        }
        int index = prefixUrl.indexOf(".");
        String target = prefixUrl.substring(0, index) + "0" + getRandomNumber() + prefixUrl.substring(index);
        target = StringUtils.replace(target, ".taobao.", ".taobaocdn.");
        if (!target.endsWith(SEP)) {
            target = target + SEP;
        }
        return target + REFUND + SEP + dbUrl;
    }
    return null;
}