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

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

Introduction

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

Prototype

public static boolean isNotEmpty(final CharSequence cs) 

Source Link

Document

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

 StringUtils.isNotEmpty(null)      = false StringUtils.isNotEmpty("")        = false StringUtils.isNotEmpty(" ")       = true StringUtils.isNotEmpty("bob")     = true StringUtils.isNotEmpty("  bob  ") = true 

Usage

From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.distributed.kubernetes.v2.KubernetesV2Utils.java

static private boolean exists(KubernetesAccount account, String namespace, String kind, String name) {
    log.info("Checking for " + kind + "/" + name);
    List<String> command = kubectlPrefix(account);

    if (StringUtils.isNotEmpty(namespace)) {
        command.add("-n");
        command.add(namespace);/*from   w  w  w  . j av a  2 s.  c  om*/
    }

    command.add("get");
    command.add(kind);
    command.add(name);

    JobRequest request = new JobRequest().setTokenizedCommand(command);

    String jobId = DaemonTaskHandler.getJobExecutor().startJob(request);

    JobStatus status;
    try {
        status = DaemonTaskHandler.getJobExecutor().backoffWait(jobId);
    } catch (InterruptedException e) {
        throw new DaemonTaskInterrupted(e);
    }

    if (status.getState() != JobStatus.State.COMPLETED) {
        throw new HalException(Problem.Severity.FATAL,
                String.join("\n", "Unterminated check for " + kind + "/" + name + " in " + namespace,
                        status.getStdErr(), status.getStdOut()));
    }

    if (status.getResult() == JobStatus.Result.SUCCESS) {
        return true;
    } else if (status.getStdErr().contains("NotFound")) {
        return false;
    } else {
        throw new HalException(Problem.Severity.FATAL,
                String.join("\n", "Failed check for " + kind + "/" + name + " in " + namespace,
                        status.getStdErr(), status.getStdOut()));
    }
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiPageTreeMacro.java

@Override
public boolean renderImpl(final GWikiContext ctx, MacroAttributes attrs) {

    ctx.append("<div id='filechooser' style='margin-top: 20px; font-family: verdana; font-size: 10px;");

    if (StringUtils.isNotEmpty(width)) {
        ctx.append("width: " + width + "; ");
    }// w  w  w  .java 2  s.co m

    if (StringUtils.isNotBlank(height)) {
        ctx.append("height: " + height + "; ");
    }

    final String path = ctx.getServlet().getServletContext().getContextPath()
            + ctx.getRequest().getServletPath();

    ctx.append("'></div>");

    ctx.append("<script type='text/javascript'>");
    ctx.append("$.jstree._themes = '" + path + "/static/js/jstree/themes/';");
    ctx.append("$(document).ready(function () {");
    ctx.append("  $(\"#filechooser\").jstree({");
    ctx.append("    \"themes\" : { \"theme\" : \"classic\", \"dots\" : true, \"icons\" : true },");
    ctx.append("    \"plugins\" : [ \"themes\", \"html_data\", \"ui\" ],");
    ctx.append("    \"html_data\" : {\n");
    ctx.append("      \"ajax\" : {");
    ctx.append("        \"url\" : ");
    ctx.append("\"").append(path);
    ctx.append("/edit/TreeChildren\",\n");
    ctx.append("        \"data\" : function(n) {   return { \"method_onLoadAsync\" : \"true\", "
            + "\"id\" : n.attr ? n.attr(\"id\") : \"" + (StringUtils.isNotBlank(rootPageId) ? rootPageId : "")
            + "\"," + "\"target\" : \"true\"" + " };      }\n");
    ctx.append("      }");
    ctx.append("    }\n");
    ctx.append("  });\n");
    ctx.append("});\n");
    ctx.append("</script>");

    ctx.flush();

    return true;
}

From source file:edu.emory.cci.aiw.cvrg.eureka.servlet.proposition.PropositionListSupport.java

String getDisplayName(PhenotypeField p) {
    String dataEltDisplayName = p.getPhenotypeDisplayName();
    if (StringUtils.isNotEmpty(dataEltDisplayName)) {
        return dataEltDisplayName + " (" + p.getPhenotypeKey() + ")";
    } else {// w w w.  j av  a  2  s  .  co  m
        return p.getPhenotypeKey();
    }
}

From source file:com.thruzero.common.jsf.utils.FlashUtils.java

/**
 * Return the "flash" attribute for the given flashHackKey; the key is unique per session and was returned when the attribute
 * was saved.// w ww . j  a  v  a  2  s  .  c o  m
 */
@SuppressWarnings("unchecked")
public static <T> T getFlashAttribute(String flashHackKey) {
    T result = null;

    if (StringUtils.isNotEmpty(flashHackKey)) {
        FlashHack flashHack = getFlashHack(false);

        if (flashHack != null) {
            result = (T) flashHack.getAttribute(flashHackKey);
        }
    }

    return result;
}

From source file:com.arrow.acs.client.model.SamlAccountModel.java

public boolean validate() {
    return StringUtils.isNotEmpty(principal)
            && (StringUtils.isNotEmpty(firstName) || StringUtils.isNotEmpty(lastName));
}

From source file:io.wcm.handler.media.markup.MediaMarkupBuilderUtil.java

/**
 * Adds CSS classes that denote the changes to the media element when compared to a different version.
 * If no diff has been requested by the WCM UI, there won't be any changes to the element.
 * @param mediaElement Element to be decorated
 * @param resource Resource pointing to JCR node
 * @param refProperty Name of property for media library item reference. If null, default name is used.
 * @param request Servlet request/*from w w  w  .ja v a 2  s.co m*/
 */
public static void addDiffDecoration(HtmlElement<?> mediaElement, Resource resource, String refProperty,
        SlingHttpServletRequest request) {

    PageManager pageManager = request.getResourceResolver().adaptTo(PageManager.class);
    Page currentPage = pageManager.getContainingPage(request.getResource());
    Page resourcePage = pageManager.getContainingPage(resource);

    String versionLabel = RequestParam.get(request, DiffService.REQUEST_PARAM_DIFF_TO);
    // Only try to diff when the resource is contained within the current page as the version number requested always
    // refers to the version history of the current page. So chances a resource on another page doesn't have a matching
    // version, and even if it has, it's comparing apples and oranges
    if (StringUtils.isNotEmpty(versionLabel) && currentPage != null && currentPage.equals(resourcePage)) {
        Resource versionedResource = DiffInfo.getVersionedResource(resource, versionLabel);
        if (versionedResource != null) {
            ValueMap currentProperties = resource.getValueMap();
            ValueMap oldProperties = versionedResource.getValueMap();

            String currentMediaRef = currentProperties.get(refProperty, String.class);
            String oldMediaRef = oldProperties.get(refProperty, String.class);
            if (!StringUtils.equals(currentMediaRef, oldMediaRef)) {
                if (StringUtils.isEmpty(currentMediaRef)) {
                    mediaElement.addCssClass(MediaNameConstants.CSS_DIFF_REMOVED);
                } else if (StringUtils.isEmpty(oldMediaRef)) {
                    mediaElement.addCssClass(MediaNameConstants.CSS_DIFF_ADDED);
                } else {
                    mediaElement.addCssClass(MediaNameConstants.CSS_DIFF_UPDATED);
                }
            } else {

                // If the mediaRef itself hasn't changed, check the cropping coordinates
                String currentMediaCrop = currentProperties.get(MediaNameConstants.PN_MEDIA_CROP, String.class);
                String oldMediaCrop = oldProperties.get(MediaNameConstants.PN_MEDIA_CROP, String.class);
                if (!StringUtils.equals(currentMediaCrop, oldMediaCrop)) {
                    mediaElement.addCssClass(MediaNameConstants.CSS_DIFF_UPDATED);
                }

                // we also could try to determine here whether it resolves to another rendition
                // or if the timestamp of the rendition has been updated (which would indicate the the binary payload has been
                // changed).
                // This however, is out of scope for this feature right now
            }
        } else {
            // The resource didn't exist in the old version at all
            mediaElement.addCssClass(MediaNameConstants.CSS_DIFF_ADDED);
        }
    }
}

From source file:com.baifendian.swordfish.common.job.struct.node.impexp.reader.MysqlReader.java

@Override
public boolean checkValid() {
    return StringUtils.isNotEmpty(datasource)
            && (StringUtils.isNotEmpty(querySql) || CollectionUtils.isNotEmpty(table));
}

From source file:architecture.ee.web.community.struts2.action.PageAction.java

public String execute() throws Exception {
    if (!isCustomized())
        return super.success();

    Page pageToUse = getTargetPage();//ww w  .  j ava2s .c o m
    if (pageToUse.getPageState() != PageState.PUBLISHED) {
        return NOT_FOUND;
    }

    if (StringUtils.isNotEmpty(pageToUse.getProperty("template", null))) {
        setTemplate(pageToUse.getProperty("template", null));
    }

    return success();
}

From source file:com.glaf.mail.web.springmvc.MailStorageController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request, ModelMap modelMap) {
    RequestUtils.setRequestParameterToAttribute(request);
    request.removeAttribute("canSubmit");
    Map<String, Object> params = RequestUtils.getParameterMap(request);
    String rowId = ParamUtils.getString(params, "storageId");
    MailStorage mailStorage = null;// w  w w . j av a 2 s. co  m
    if (StringUtils.isNotEmpty(rowId)) {
        mailStorage = mailStorageService.getMailStorage(rowId);
        request.setAttribute("mailStorage", mailStorage);
    }

    String view = request.getParameter("view");
    if (StringUtils.isNotEmpty(view)) {
        return new ModelAndView(view, modelMap);
    }

    String x_view = CustomProperties.getString("mailStorage.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view, modelMap);
    }

    return new ModelAndView("/modules/mail/mailStorage/edit", modelMap);
}

From source file:com.springstudy.utils.email.MimeMailService.java

/**
 * ??MIME?./* ww w .  jav  a  2  s  .  co m*/
 */
public boolean sendNotificationMail(com.gmk.framework.common.utils.email.Email email) {
    try {
        MimeMessage msg = mailSender.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(msg, true, DEFAULT_ENCODING);
        //??????
        String from = Global.getConfig("productName");
        if (StringUtils.isNotEmpty(email.getFrom())) {
            from = from + "-" + email.getFrom();
        }
        helper.setFrom(Global.getConfig("mailFrom"), from);
        helper.setTo(email.getAddress());
        if (StringUtils.isNotEmpty(email.getCc())) {
            String cc[] = email.getCc().split(";");
            helper.setCc(cc);//?
        }
        //
        helper.setSubject(email.getSubject());
        //
        if (StringUtils.isNotEmpty(email.getTemplate())) {
            String content = generateContent(email.getTemplate(), email.getContentMap());
            helper.setText(content, true);
        } else {
            helper.setText(email.getContent());
        }
        //
        if (ListUtils.isNotEmpty(email.getAttachment())) {
            for (File file : email.getAttachment()) {
                helper.addAttachment(MimeUtility.encodeWord(file.getName()), file);
            }
        }
        mailSender.send(msg);
        logger.info("HTML??");
        return true;
    } catch (MessagingException e) {
        logger.error(email.getAddressee() + "-" + email.getSubject() + "-" + "", e);
    } catch (Exception e) {
        logger.error(email.getAddressee() + "-" + email.getSubject() + "-" + "??", e);
    }
    return false;
}