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.glaf.ui.web.springmvc.MxSkinController.java

@RequestMapping(value = "/save", method = RequestMethod.POST)
public String save(@RequestParam("skinId") String skinId, HttpServletRequest request) {
    LoginContext loginContext = RequestUtils.getLoginContext(request);
    String actorId = loginContext.getActorId();
    if (StringUtils.isNotEmpty(skinId)) {
        skinService.saveUserSkin(actorId, skinId);
    }//from  w w w.  j av  a2 s. co  m
    return LIST_ACTION;
}

From source file:com.glaf.survey.website.springmvc.PublicSurveyController.java

@ResponseBody
@RequestMapping("/post/{id}")
public byte[] post(@PathVariable("id") String id, HttpServletRequest request) throws IOException {
    Survey survey = null;/*from  www.j a v a2 s .c o  m*/
    if (StringUtils.isNotEmpty(id)) {
        survey = surveyService.getSurvey(Long.parseLong(id));
        if (survey != null) {
            if (survey.getStatus() != 1) {
                return ResponseUtils.responseJsonResult(false,
                        "???");
            }
            Date now = new Date();
            if (survey.getEndDate() != null && survey.getEndDate().getTime() < now.getTime()) {
                return ResponseUtils.responseJsonResult(false,
                        "???");
            }
            String ip = RequestUtils.getIPAddress(request);
            if (survey.getLimitFlag() == 1) {// ??IP?
                SurveyResult result = surveyService.getLatestSurveyResult(survey.getId(), ip);
                if (result != null) {
                    Date surveyDate = result.getSurveyDate();
                    long ts = now.getTime() - surveyDate.getTime();
                    if (ts / (1000 * 60) <= survey.getLimitTimeInterval()) {
                        return ResponseUtils.responseJsonResult(false,
                                "???");
                    }
                }
            }
            if (survey.getRelations() != null && !survey.getRelations().isEmpty()) {
                List<SurveyResult> surveyResults = new java.util.ArrayList<SurveyResult>();
                for (Survey relation : survey.getRelations()) {
                    SurveyResult result = new SurveyResult();
                    result.setIp(ip);
                    result.setSurveyId(relation.getId());
                    result.setSurveyDate(new Date());
                    result.setResult(request.getParameter("result_" + relation.getId()));
                    surveyResults.add(result);
                }
                surveyResultService.saveAll(surveyResults);
            } else {
                SurveyResult result = new SurveyResult();
                result.setIp(ip);
                result.setSurveyId(survey.getId());
                result.setSurveyDate(new Date());
                result.setResult(request.getParameter("result"));
                surveyResultService.save(result);
            }
            return ResponseUtils.responseJsonResult(true, "????");
        }
    }
    return ResponseUtils.responseJsonResult(false, "??????");
}

From source file:com.pinterest.secor.parser.ThriftMessageParser.java

public ThriftMessageParser(SecorConfig config)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    super(config);
    TProtocolFactory protocolFactory = null;
    String protocolName = mConfig.getThriftProtocolClass();

    if (StringUtils.isNotEmpty(protocolName)) {
        String factoryClassName = protocolName.concat("$Factory");
        protocolFactory = ((Class<? extends TProtocolFactory>) Class.forName(factoryClassName)).newInstance();
    } else//from w  ww. j  ava 2 s.  co m
        protocolFactory = new TBinaryProtocol.Factory();

    mDeserializer = new TDeserializer(protocolFactory);
    mThriftPath = new ThriftPath(mConfig.getMessageTimestampName(), (short) mConfig.getMessageTimestampId());
    mTimestampType = mConfig.getMessageTimestampType();
}

From source file:com.bekwam.resignator.model.JarsignerConfig.java

@Override
public String toString() {
    return "JarsignerConfig{" + "alias='" + alias + '\'' + ", storepass not empty?='"
            + StringUtils.isNotEmpty(storepass) + '\'' + ", keypass not empty?='"
            + StringUtils.isNotEmpty(keypass) + '\'' + ", keystore='" + keystore + '\'' + ", verbose=" + verbose
            + '\'' + ", encStorepass not empty?='" + StringUtils.isNotEmpty(encryptedStorepass) + '\''
            + ", encKeypass not empty?='" + StringUtils.isNotEmpty(encryptedKeypass) + '}';
}

From source file:io.knotx.knot.service.service.ServiceEntry.java

public ServiceEntry setCacheKey(String newCacheKey) {
    if (StringUtils.isNotEmpty(newCacheKey)) {
        this.cacheKey = newCacheKey;
    }/* w w  w  . j  a va  2  s. co  m*/
    return this;
}

From source file:iqq.app.core.service.impl.SkinServiceImpl.java

/**
 * ?//from   w  w  w . ja v  a2 s .c o  m
 *
 * @param key
 * @return
 */
@Override
public Color getColorByKey(String key) {
    if (StringUtils.isNotEmpty(key)) {
        try {
            // ???
            String color = XmlUtils.getNodeText(getSkinConfig(), key);
            return Color.decode(color);
        } catch (NullPointerException e) {
            // ????
            String color = null;
            try {
                // getDefaultConfig()??
                color = XmlUtils.getNodeText(getDefaultConfig(), key);
            } catch (NullPointerException e1) {
                LOG.error("?, key=" + key, e1);
            } catch (DocumentException e2) {
                LOG.error("?, key=" + key, e2);
            }
            return Color.decode(color);
        } catch (DocumentException e) {
            LOG.error("?, key=" + key, e);
        }
    }
    return null;
}

From source file:info.mikaelsvensson.devtools.report.HtmlFileCreator.java

private SinkEventAttributeSet createAttributeSet(final String cssClass) {
    SinkEventAttributeSet set = new SinkEventAttributeSet();
    if (StringUtils.isNotEmpty(cssClass)) {
        set.addAttribute(SinkEventAttributeSet.CLASS, cssClass);
    }// w w w . jav  a  2 s. c  o  m
    return set;
}

From source file:com.glaf.chart.util.ChartUtils.java

public static void createChart(String path, Chart chartModel, JFreeChart chart) {
    try {//from www .j  ava  2 s . c  om
        java.awt.image.BufferedImage bi = chart.createBufferedImage(chartModel.getChartWidth(),
                chartModel.getChartHeight());

        String name = chartModel.getChartName();
        if (StringUtils.isNotEmpty(chartModel.getMapping())) {
            name = chartModel.getMapping();
        }

        if ("png".equalsIgnoreCase(chartModel.getImageType())) {
            EncoderUtil.writeBufferedImage(bi, chartModel.getImageType(),
                    new FileOutputStream(path + "/" + name + ".png"));
            ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            ServletUtilities.saveChartAsPNG(chart, chartModel.getChartWidth(), chartModel.getChartHeight(),
                    info, null);
        } else if ("jpeg".equalsIgnoreCase(chartModel.getImageType())) {
            EncoderUtil.writeBufferedImage(bi, chartModel.getImageType(),
                    new FileOutputStream(path + "/" + name + ".jpg"));
            ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
            ServletUtilities.saveChartAsJPEG(chart, chartModel.getChartWidth(), chartModel.getChartHeight(),
                    info, null);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex);
    }
}

From source file:com.glaf.oa.paymentplan.web.springmvc.PaymentplanController.java

@ResponseBody
@RequestMapping("/delete")
public void delete(HttpServletRequest request, ModelMap modelMap) {
    Long planid = RequestUtils.getLong(request, "planid");
    String planids = request.getParameter("planids");
    if (StringUtils.isNotEmpty(planids)) {
        StringTokenizer token = new StringTokenizer(planids, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                Paymentplan paymentplan = paymentplanService.getPaymentplan(Long.valueOf(x));
                /**/*from  ww  w  .ja v  a 2 s .c  o  m*/
                 * 
                 */
                if (paymentplan != null) {
                    paymentplanService.deleteById((paymentplan.getPlanid()));
                }
            }
        }
    } else if (planid != null) {
        Paymentplan paymentplan = paymentplanService.getPaymentplan(Long.valueOf(planid));
        /**
         * 
         */
        if (paymentplan != null) {
            paymentplanService.deleteById((paymentplan.getPlanid()));
        }
    }
}

From source file:com.glaf.jbpm.web.springmvc.MxJbpmExtensionController.java

@RequestMapping("/edit")
public ModelAndView edit(HttpServletRequest request) {

    String processName = request.getParameter("processName");
    String taskName = request.getParameter("taskName");
    if (StringUtils.isNotEmpty(processName) && StringUtils.isNotEmpty(taskName)) {

    }//  w w  w.j  a  v  a2s  .c  om
    JbpmExtensionManager jbpmExtensionManager = ProcessContainer.getContainer().getJbpmExtensionManager();
    JbpmContext jbpmContext = null;
    try {
        jbpmContext = ProcessContainer.getContainer().createJbpmContext();
        Extension extension = jbpmExtensionManager.getExtensionTask(jbpmContext, processName, taskName);
        request.setAttribute("extension", extension);
    } catch (Exception ex) {
        request.setAttribute("error_code", 9920);
        return new ModelAndView("/error");
    } finally {
        Context.close(jbpmContext);
    }

    String jx_view = request.getParameter("jx_view");

    if (StringUtils.isNotEmpty(jx_view)) {
        return new ModelAndView(jx_view);
    }

    String x_view = ViewProperties.getString("jbpm_extension.edit");
    if (StringUtils.isNotEmpty(x_view)) {
        return new ModelAndView(x_view);
    }

    return new ModelAndView("/jbpm/extension/edit");
}