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.btobits.automator.fix.comparator.MailComparator.java

public static void compare(final FixMessageType inMsg, final SMTPMessage inSmtpMessage) throws Exception {

    final List<String> errors = new ArrayList<String>();
    try {/*from   w  w  w. j a  va 2 s.  c  om*/
        // compare header field             
        for (final FixMessageType.Field field : inMsg.getFields()) {
            if (!field.isGroup()) {
                final String value = getHeaderField(field.getName(), inSmtpMessage);
                if (StringUtils.isBlank(value) && StringUtils.isBlank(field.getValue())) {
                    continue;
                } else if (StringUtils.isBlank(value)) {
                    errors.add("Field [" + field.getName() + "] is absend in receive email.");
                } else if (!StringUtils.equals(field.getValue(), value) && StringUtils.startsWith(value, "<")
                        && StringUtils.endsWith(value, ">")) {

                    final String subValue = StringUtils.substringBetween(value, "<", ">");
                    if (StringUtils.isBlank(subValue)) {
                        errors.add("Field [" + field.getName() + "] is not eq receive email field ['"
                                + field.getValue() + " != " + value + "'].");
                    } else if (!StringUtils.equalsIgnoreCase(subValue, field.getValue())) {
                        errors.add("Field [" + field.getName() + "] is not eq receive email field ['"
                                + field.getValue() + " != " + value + "'].");
                    }
                } else if (!StringUtils.equals(field.getValue(), value)) {
                    errors.add("Field [" + field.getName() + "] is not eq receive email field ['"
                            + field.getValue() + " != " + value + "'].");
                }
            } else {
                // compare group
                final List<String> body = getDataFields(inSmtpMessage);
                final LinkedList<FixMessageType.Field> fields = field.getFields();
                int count = 0;
                for (FixMessageType.Field grFld : fields) {
                    final String value = getValueOnPosition(body, count);
                    if (StringUtils.equals(grFld.getName(), FIX_MESSAGE_FLD)) {
                        String fixMessage = getFixField("Original FIX message:", inSmtpMessage);
                        if (!StringUtils.equals(fixMessage, grFld.getValue())) {
                            errors.add(
                                    "Data fix field [" + grFld.getName() + "] is not eq receive email field ['"
                                            + grFld.getValue() + " != " + fixMessage + "'].");
                        }
                    } else {
                        if (StringUtils.isBlank(value) && StringUtils.isBlank(grFld.getValue())) {
                        } else {
                            if (!StringUtils.equals(value, grFld.getValue())) {
                                errors.add(
                                        "Data field [" + grFld.getName() + "] is not eq receive email field ['"
                                                + grFld.getValue() + " != " + value + "'].");
                            }
                        }
                    }
                    count++;
                }
            }
        }
    } catch (Exception ex) {
        throw new BuildException("Error compare message", ex);
    }

    if (!errors.isEmpty()) {
        throw new MessageDifferenceException(FixUtils.toString(errors));
    }
}

From source file:io.github.jeddict.collaborate.issues.ExceptionUtils.java

public static void printStackTrace(String errorMessage, final Throwable t, final ModelerFile file) {
    t.printStackTrace();// w w  w.ja  v a  2 s  . co m
    if (StringUtils.isBlank(errorMessage)) {
        errorMessage = t.getMessage();

        if (StringUtils.isBlank(errorMessage)) {
            if (t.getCause() != null && StringUtils.isNotBlank(t.getCause().getMessage())) {
                errorMessage = t.getCause().getMessage();
            } else if (t.getStackTrace().length > 0) {
                errorMessage = t.getStackTrace()[0].toString();
            }
        }
    }
    final String message = errorMessage;
    LOG.log(Level.ALL, errorMessage, t);
    String content = file != null ? file.getContent() : "";
    SwingUtilities.invokeLater(() -> {
        ExceptionReporterPanel exceptionReporterPanel = new ExceptionReporterPanel(message, t, content);
        exceptionReporterPanel.setVisible(true);
    });
}

From source file:com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer.java

@Override
public String execute(String content) {
    if (StringUtils.isBlank(content)) {
        return content;
    }//from  w  ww . j  av  a2 s .c  o m
    Locale locale;
    try {
        locale = LocaleUtils.toLocale(content);
    } catch (Exception e) {
        return getDefaultLocale(content);
    }
    if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
        return getDefaultLocale(content);
    }
    return locale.toString();
}

From source file:edu.sampleu.travel.remotedservice.SampleRemotedService.java

public void invoke(String message) {
    if (StringUtils.isBlank(message)) {
        throw new RiceIllegalArgumentException("message is null or blank");
    }/*w w  w  .  j ava 2s .com*/

    System.out.println("A MESSAGE WAS RECIEVED!!!");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("");
    System.out.println("THE MESSAGE WAS -->" + message);
}

From source file:com.tc.config.Directories.java

/**
 * Get installation root directory.//from  w w  w.  ja va  2s. c  om
 * 
 * @return Installation root directory or null if TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME is set and
 *         TC_INSTALL_ROOT_PROPERTY_NAME is not.
 * @throws FileNotFoundException If {@link #TC_INSTALL_ROOT_PROPERTY_NAME} has not been set. If
 *         {@link #TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME} has not been set, this exception may be thrown if the
 *         installation root directory has not been set, is not a directory
 */
public static File getInstallationRoot() throws FileNotFoundException {
    boolean ignoreCheck = Boolean.getBoolean(TC_INSTALL_ROOT_IGNORE_CHECKS_PROPERTY_NAME);
    if (ignoreCheck) {
        // XXX hack to have enterprise system tests to find license key under <ee-branch>/code/base
        String baseDir = System.getProperty("tc.base-dir");
        return new File(baseDir != null ? baseDir : ".", "../../../code/base");
    } else {
        String path = System.getProperty(TC_INSTALL_ROOT_PROPERTY_NAME);
        if (StringUtils.isBlank(path)) {
            // formatting
            throw new FileNotFoundException("The system property '" + TC_INSTALL_ROOT_PROPERTY_NAME
                    + "' has not been set. As such, the Terracotta installation directory cannot be located.");
        }

        File rootPath = new File(path).getAbsoluteFile();
        if (!rootPath.isDirectory()) {
            // formatting
            throw new FileNotFoundException("The specified Terracotta installation directory, '" + rootPath
                    + "', located via the value of the system property '" + TC_INSTALL_ROOT_PROPERTY_NAME
                    + "', does not actually exist.");
        }
        return rootPath;
    }
}

From source file:com.enonic.cms.core.content.contentdata.custom.MultipleChoiceDataEntry.java

public boolean breaksRequiredContract() {
    if (alternatives == null || text == null) {
        return true;
    }//from  w  w w  .  java2  s . c  o m
    if (alternatives.size() < 2) {
        return true;
    }
    return StringUtils.isBlank(text);
}

From source file:com.haulmont.cuba.gui.xml.layout.loaders.ButtonLoader.java

protected void loadInvoke(Button component, boolean enabled, boolean visible, Element element) {
    if (!StringUtils.isBlank(element.attributeValue("action"))) {
        return;/* www . j  ava  2s  .c  o m*/
    }

    final String methodName = element.attributeValue("invoke");
    if (StringUtils.isBlank(methodName)) {
        return;
    }

    String actionBaseId = component.getId();
    if (StringUtils.isEmpty(actionBaseId)) {
        actionBaseId = methodName;
    }

    DeclarativeAction action = new DeclarativeAction(actionBaseId + "_invoke", component.getCaption(),
            component.getDescription(), component.getIcon(), enabled, visible, methodName,
            component.getFrame());
    component.setAction(action);
}

From source file:de.hybris.platform.accountsummaryaddon.attributehandlers.B2BPaymentMethodDynamicAttributeHandler.java

@Override
public String get(final B2BDocumentPaymentInfoModel ruleSet) {
    final boolean usingDocument = StringUtils.isBlank(ruleSet.getCcTransactionNumber());
    if (usingDocument) {
        return ruleSet.getUseDocument().getDocumentType().getName();
    } else {//from w w  w.jav  a 2s.  c o m
        return Localization.getLocalizedString(ACCOUNTSUMMARY_CC_PAYMENT);
    }
}

From source file:com.github.steveash.typedconfig.keycombine.DelimitedKeyCombinationStrategy.java

@Override
public String combineKey(String baseKey, String localKey, HierarchicalConfiguration config) {
    String delim = getDelimiter();
    if (StringUtils.isBlank(baseKey))
        return localKey;

    if (baseKey.endsWith(delim) && localKey.startsWith(delim))
        return baseKey + localKey.substring(1);

    if (baseKey.endsWith(delim) || localKey.startsWith(delim))
        return baseKey + localKey;

    return baseKey + delim + localKey;
}

From source file:io.kahu.hawaii.util.logger.Log4jConfigListener.java

@Override
public void contextInitialized(ServletContextEvent sce) {
    String config = System.getenv("log4j.configuration");
    if (StringUtils.isBlank(config)) {
        config = System.getProperty("log4j.configuration");
    }/* w  w w . j av a  2s.c  o  m*/
    if (StringUtils.isNotEmpty(config)) {
        String overrideConfig = StringUtils.replace(config, ".xml", ".local.xml");
        if (!configureAndWatch(overrideConfig)) {
            configureAndWatch(config);
            sce.getServletContext().log("Configured to watch log configuration '" + config + "'");
        } else {
            sce.getServletContext().log("Configured to watch log configuration '" + overrideConfig + "'");
        }
    }
}