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.baifendian.swordfish.common.job.struct.node.impexp.writer.HdfsWriter.java

/**
 * fieldDelimiter??//from   w  w  w  . j  av a2  s  .com
 *
 * @return
 */
private boolean checkFieldDelimiter(String fieldDelimiter) {
    return StringUtils.isNotEmpty(fieldDelimiter) && !StringUtils.equalsIgnoreCase(fieldDelimiter, "\n");
}

From source file:com.tethrnet.manage.util.SSHUtil.java

/**
 * returns the system's public key//w ww. j  a  v  a 2  s.c  o m
 *
 * @return system's public key
 */
public static String getPublicKey() {

    String publicKey = PUB_KEY;
    //check to see if pub/pvt are defined in properties
    if (StringUtils.isNotEmpty(AppConfig.getProperty("privateKey"))
            && StringUtils.isNotEmpty(AppConfig.getProperty("publicKey"))) {
        publicKey = AppConfig.getProperty("publicKey");
    }
    //read pvt ssh key
    File file = new File(publicKey);
    try {
        publicKey = FileUtils.readFileToString(file);
    } catch (Exception ex) {
        log.error(ex.toString(), ex);
    }

    return publicKey;
}

From source file:com.glaf.core.jdbc.datasource.MultiRoutingDataSource.java

private static void reloadDS() {
    if (!loading.get()) {
        try {/*from  ww w. jav  a2 s  .  c o  m*/
            loading.set(true);
            logger.info("--------------MultiRoutingDataSource reloadDS()------------");
            Map<Object, Object> dataSourceMap = new java.util.HashMap<Object, Object>();
            Map<String, Properties> dataSourceProperties = DBConfiguration.getDataSourceProperties();
            Set<Entry<String, Properties>> entrySet = dataSourceProperties.entrySet();
            for (Entry<String, Properties> entry : entrySet) {
                String name = entry.getKey();
                Properties props = entry.getValue();
                if (props != null && StringUtils.isNotEmpty(name)) {
                    try {
                        ConnectionProvider provider = ConnectionProviderFactory.createProvider(name);
                        if (provider != null) {
                            dataSourceMap.put(name, provider.getDataSource());
                            if (StringUtils.equals(name, Environment.DEFAULT_SYSTEM_NAME)) {
                                defaultTargetDataSource = provider.getDataSource();
                            }
                        }
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        logger.error(ex);
                    }
                }
            }

            if (defaultTargetDataSource == null) {
                Properties props = DBConfiguration.getProperties(Environment.DEFAULT_SYSTEM_NAME);
                if (props != null) {
                    ConnectionProvider provider = ConnectionProviderFactory
                            .createProvider(Environment.DEFAULT_SYSTEM_NAME, props);
                    dataSourceMap.put(Environment.DEFAULT_SYSTEM_NAME, provider.getDataSource());
                }
            }

            targetDataSources.putAll(dataSourceMap);

            logger.info("##datasources:" + targetDataSources.keySet());

        } catch (Exception ex) {
            logger.error(ex);
            ex.printStackTrace();
            throw new RuntimeException(ex);
        } finally {
            loading.set(false);
        }
    }
}

From source file:com.glaf.activiti.web.springmvc.ActivitiMonitorController.java

@RequestMapping("/addGroupIdentityLink")
@ResponseBody//from w  w  w. j  a  v  a  2  s. c o m
public byte[] addGroupIdentityLink(HttpServletRequest request) {
    String taskId = request.getParameter("taskId");
    String groupIds = request.getParameter("groupIds");
    String identityLinkType = request.getParameter("identityLinkType");
    if (StringUtils.isEmpty(identityLinkType)) {
        identityLinkType = IdentityLinkType.CANDIDATE;
    }
    boolean success = false;
    if (StringUtils.isNotEmpty(groupIds) && StringUtils.isNotEmpty(taskId)) {
        Task task = activitiTaskQueryService.getTask(taskId);
        List<String> groups = StringTools.split(groupIds);
        if (task != null && groups != null && groups.size() > 0) {
            activitiProcessService.addGroupIdentityLink(taskId, groupIds, identityLinkType);
            success = true;
        }
    }
    return ResponseUtils.responseResult(success);
}

From source file:com.netflix.spinnaker.echo.pubsub.google.GooglePubsubEventListener.java

private void publishEvent(GooglePubsubPublisher p, Event event) {
    String jsonPayload;//from  w ww. ja  v a 2 s  .c om
    try {
        jsonPayload = mapper.writeValueAsString(event);
    } catch (JsonProcessingException jpe) {
        log.error("Could not serialize event message: {}", jpe);
        return;
    }

    Map<String, String> attributes = new HashMap<>();
    if (event.getDetails() != null) {
        Metadata m = event.getDetails();

        String rawType = m.getType();
        if (StringUtils.isNotEmpty(rawType)) {
            attributes.put("rawType", rawType);

            String[] eventDetails = rawType.split(":");
            if (eventDetails.length == 3) {
                attributes.put("source", eventDetails[0]);
                attributes.put("type", eventDetails[1]);
                attributes.put("status", eventDetails[2]);
            }
        }

        if (StringUtils.isNotEmpty(m.getApplication())) {
            attributes.put("application", m.getApplication());
        }

        if (m.getAttributes() != null && !m.getAttributes().isEmpty()) {
            attributes.putAll(m.getAttributes());
        }
    }

    if (event.getContent() != null && !event.getContent().isEmpty()) {
        Map content = event.getContent();

        String name = content.getOrDefault("name", "").toString();
        if (StringUtils.isNotEmpty(name)) {
            attributes.put("name", name);
        }

        String taskName = content.getOrDefault("taskName", "").toString();
        if (StringUtils.isNotEmpty(taskName)) {
            attributes.put("taskName", taskName);
        }
    }

    p.publish(jsonPayload, attributes);
}

From source file:com.msg.wmTestHelper.codeModel.part.WaitStepPart.java

private String evaluateTypeOfWaitStep(ProcessStep processStep) {
    String documentName = processStep.message().documentName();

    if (StringUtils.isNotEmpty(documentName)) {
        if (ProprietaryHelper.getConfig("wait.1.startmessage").equals(documentName)) {
            return ProprietaryHelper.getConfig("wait.1.name");
        } else if (ProprietaryHelper.getConfig("wait.2.startmessage").equals(documentName)) {
            return ProprietaryHelper.getConfig("wait.2.name");
        } else if (ProprietaryHelper.getConfig("wait.3.startmessage").equals(documentName)) {
            return ProprietaryHelper.getConfig("wait.3.name");
        }/*w ww  .j  a  v a2s. c  o m*/
    }

    log.warn("Could not evaluate type of wait step");

    return StringUtils.EMPTY;
}

From source file:com.smartling.api.sdk.util.HttpProxyUtils.java

private static boolean proxyAuthenticationRequired(final ProxyConfiguration proxyConfiguration) {
    return hasActiveProxyConfiguration(proxyConfiguration)
            && StringUtils.isNotEmpty(proxyConfiguration.getUsername())
            && StringUtils.isNotEmpty(proxyConfiguration.getPassword());
}

From source file:com.glaf.base.modules.sys.springmvc.SysSchedulerController.java

@RequestMapping(params = "method=locked")
public ModelAndView locked(HttpServletRequest request, ModelMap modelMap) {
    String taskId = request.getParameter("taskId");
    int locked = 0;
    Scheduler scheduler = null;/*from   www . j a v a 2  s.  c  om*/
    if (StringUtils.isNotEmpty(taskId)) {
        scheduler = sysSchedulerService.getSchedulerByTaskId(taskId);
        if (scheduler != null) {
            sysSchedulerService.locked(taskId, locked);
            if (scheduler.getLocked() == 1) {
                QuartzUtils.stop(taskId);
            }
        }
    }
    return this.showList(request, modelMap);
}

From source file:com.glaf.oa.travelpersonnel.web.springmvc.TravelpersonnelController.java

@ResponseBody
@RequestMapping("/delete")
public void delete(HttpServletRequest request, ModelMap modelMap) {
    Long personnelid = RequestUtils.getLong(request, "personnelid");
    String personnelids = request.getParameter("personnelids");
    if (StringUtils.isNotEmpty(personnelids)) {
        StringTokenizer token = new StringTokenizer(personnelids, ",");
        while (token.hasMoreTokens()) {
            String x = token.nextToken();
            if (StringUtils.isNotEmpty(x)) {
                Travelpersonnel travelpersonnel = travelpersonnelService.getTravelpersonnel(Long.valueOf(x));
                /**/* w w  w .ja v a 2 s  . c  o  m*/
                 * 
                 */
                if (travelpersonnel != null) {
                    // travelpersonnel.setDeleteFlag(1);
                    travelpersonnelService.deleteById(Long.valueOf(x));
                }
            }
        }
    } else if (personnelid != null) {
        Travelpersonnel travelpersonnel = travelpersonnelService.getTravelpersonnel(personnelid);
        /**
         * 
         */
        if (travelpersonnel != null) {
            // travelpersonnel.setDeleteFlag(1);
            travelpersonnelService.deleteById(personnelid);
        }
    }
}

From source file:de.inetsource.jsfforum.beans.ThreadBean.java

@PostConstruct
public void init() {
    Map<String, String> parameter = FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap();/*from www  .j  ava2  s.c  o  m*/
    if (StringUtils.isNotEmpty(parameter.get("forumId"))) {
        forumId = Integer.valueOf(parameter.get("forumId"));
        threads = threadFacade.findArticlesFromTopic(forumId);
        forum = forumFacade.find(forumId);
        for (Thread t : threads) {
            t.setLastPost(threadFacade.getLastPost(t));
            t.setFirstPost(threadFacade.getFirstPost(t));
        }
    }
    thread = new Thread();
}