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

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

Introduction

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

Prototype

public static boolean isNotEmpty(String str) 

Source Link

Document

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

Usage

From source file:com.haulmont.cuba.desktop.gui.icons.IconResolverImpl.java

@Override
public Icon getIconResource(String icon) {
    if (StringUtils.isEmpty(icon)) {
        return null;
    }/*from w ww .j av a  2 s.c  o m*/

    String themeIcon = App.getInstance().getThemeConstants().get("icons." + processPath(icon));

    if (StringUtils.isNotEmpty(themeIcon)) {
        return getResource(themeIcon);
    }

    return getResource(icon);
}

From source file:com.vmware.appfactory.recipe.RecipeMatch.java

/**
 * Compare a string value from a recipe key to a string value from an
 * application, and return what kind of a match that is.
 * @param keyValue//from   w w w .j  a va  2  s . c  o  m
 * @param appValue
 * @return
 */
public static RecipeMatch match(String keyValue, String appValue) {
    if (StringUtils.isEmpty(keyValue) && StringUtils.isEmpty(appValue)) {
        /* Both empty: that's a precise match */
        return precise;
    } else if (StringUtils.isEmpty(keyValue) && StringUtils.isNotEmpty(appValue)) {
        /* Key is empty, value is not: that's a partial match */
        return partial;
    } else if (keyValue.equals(appValue)) {
        /* Both the same: that's a precise match */
        return precise;
    }

    return none;
}

From source file:gov.nih.nci.cabig.caaers.web.rule.ManageSafetyNotificationCommand.java

public void syncRecipients() {

    ArrayList<String> eList = new ArrayList<String>();
    if (CollectionUtils.isNotEmpty(recipientEmails)) {
        for (String s : recipientEmails)
            if (StringUtils.isNotEmpty(s))
                eList.add(s);/* www  .  ja  va  2 s .  c  o m*/
    }
    notification.setRecipientEmails(eList);

    ArrayList<String> rList = new ArrayList<String>();
    if (CollectionUtils.isNotEmpty(recipientRoles)) {
        for (String s : recipientRoles)
            if (StringUtils.isNotEmpty(s))
                rList.add(s);
    }
    notification.setRecipientRoles(rList);
}

From source file:net.shopxx.interceptor.TokenInterceptor.java

@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
        throws Exception {
    String token = WebUtils.getCookie(request, TOKEN_COOKIE_NAME);
    if (StringUtils.equalsIgnoreCase(request.getMethod(), "POST")) {
        if (StringUtils.isNotEmpty(token)) {
            String requestType = request.getHeader("X-Requested-With");
            if (StringUtils.equalsIgnoreCase(requestType, "XMLHttpRequest")) {
                if (StringUtils.equals(token, request.getHeader(TOKEN_PARAMETER_NAME))) {
                    return true;
                } else {
                    response.addHeader("tokenStatus", "accessDenied");
                }/*from  w  ww .j a va2 s . co  m*/
            } else {
                if (StringUtils.equals(token, request.getParameter(TOKEN_PARAMETER_NAME))) {
                    return true;
                }
            }
        } else {
            WebUtils.addCookie(request, response, TOKEN_COOKIE_NAME,
                    DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30)));
        }
        response.sendError(HttpServletResponse.SC_FORBIDDEN, ERROR_MESSAGE);
        return false;
    } else {
        if (StringUtils.isEmpty(token)) {
            token = DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30));
            WebUtils.addCookie(request, response, TOKEN_COOKIE_NAME, token);
        }
        request.setAttribute(TOKEN_ATTRIBUTE_NAME, token);
        return true;
    }
}

From source file:com.dp2345.service.impl.CaptchaServiceImpl.java

public boolean isValid(CaptchaType captchaType, String captchaId, String captcha) {
    Setting setting = SettingUtils.get();
    if (captchaType == null || ArrayUtils.contains(setting.getCaptchaTypes(), captchaType)) {
        if (StringUtils.isNotEmpty(captchaId) && StringUtils.isNotEmpty(captcha)) {
            try {
                return imageCaptchaService.validateResponseForID(captchaId, captcha.toUpperCase());
            } catch (Exception e) {
                return false;
            }/*from  w w  w.j ava  2s  .com*/
        } else {
            return false;
        }
    } else {
        return true;
    }
}

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

@Override
public void loadComponent() {
    super.loadComponent();

    loadMaxLength(resultComponent, element);

    String autocomplete = element.attributeValue("autocomplete");
    if (StringUtils.isNotEmpty(autocomplete)) {
        resultComponent.setAutocomplete(Boolean.parseBoolean(autocomplete));
    }//ww w.  ja v a 2  s  .  c  o m
}

From source file:gov.nih.nci.cabig.caaers.web.ae.ReconciliationReportController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    String strReportId = request.getParameter("rrId");
    ReconciliationReport report = null;/*from w w  w .  java2  s .  co m*/

    if (StringUtils.isNotEmpty(strReportId)) {
        report = reconciliationReportDao.getById(Integer.parseInt(strReportId));
    } else {
        report = (ReconciliationReport) request.getAttribute("report");
    }
    ModelAndView mv = new ModelAndView();
    mv.addObject("report", report);
    mv.setViewName("ae/ae_reconcile_report");
    return mv;
}

From source file:com.sforce.cd.apexUnit.client.OAuthTokenGeneratorTest.java

@Test
public void getOrgToken() {
    String orgToken = "";
    // generate/get the orgToken and test if the token has been generated
    orgToken = OAuthTokenGenerator.getOrgToken();
    LOG.debug(orgToken + "  -->  This is the orgToken");
    Assert.assertNotEquals(orgToken, null);
    Assert.assertTrue(StringUtils.isNotEmpty(orgToken));
}

From source file:com.assemblade.opendj.LdapUtils.java

public static void createSingleEntryModification(List<Modification> modifications, Entry currentEntry,
        String attributeName, String value) {
    AttributeType type = DirectoryServer.getAttributeType(attributeName);
    AttributeBuilder builder = new AttributeBuilder(type);
    if (currentEntry.hasAttribute(type)) {
        if (StringUtils.isEmpty(value)) {
            modifications.add(new Modification(ModificationType.DELETE, builder.toAttribute()));
        } else {// www .ja  va 2s .  c  o  m
            String oldValue = getSingleAttributeStringValue(currentEntry.getAttribute(attributeName));
            if (!StringUtils.equals(oldValue, value)) {
                builder.add(value);
                modifications.add(new Modification(ModificationType.REPLACE, builder.toAttribute()));
            }
        }
    } else {
        if (StringUtils.isNotEmpty(value)) {
            builder.add(value);
            modifications.add(new Modification(ModificationType.ADD, builder.toAttribute()));
        }
    }
}

From source file:info.magnolia.cms.gui.dialog.DialogTab.java

public void drawHtmlPreSubs(Writer out) throws IOException {
    String parentId = this.getParent().getId();
    String id = this.getId();
    // add tab button to tab set
    if (StringUtils.isNotEmpty(this.getLabel())) {
        Button control = new Button();
        control.setLabel(this.getMessage(this.getLabel()));
        control.setOnclick("mgnlDialogShiftTab('" + parentId + "','" + id + "');"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        this.getParent().addOption(control);
    }//from   ww  w .j av  a 2s.c o m
    // add tab to js object
    out.write("<script type=\"text/javascript\">"); //$NON-NLS-1$
    out.write("mgnlControlSets['" //$NON-NLS-1$
            + parentId + "'].items[mgnlControlSets['" //$NON-NLS-1$
            + parentId + "'].items.length]='" //$NON-NLS-1$
            + id + "';"); //$NON-NLS-1$
    out.write("</script>"); //$NON-NLS-1$
    // tab page
    out.write("<div id=\"" + id + "_div\" class=\"" + CssConstants.CSSCLASS_TAB + "\">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    out.write("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">"); //$NON-NLS-1$
    out.write("<tr><td class=\"" + CssConstants.CSSCLASS_TAB + "\">"); //$NON-NLS-1$ //$NON-NLS-2$
    out.write(
            "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" style=\"table-layout:fixed\">"); //$NON-NLS-1$
    out.write("<col width=\"200\" /><col />"); //$NON-NLS-1$
}