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.inkubator.hrm.web.recruitment.RecruitAdvertisementCategoryFormController.java

@PostConstruct
@Override/* w ww. jav  a2s  .c  o  m*/
public void initialization() {
    super.initialization();
    try {
        String recruitAdvertisementCategoryId = FacesUtil.getRequestParameter("recruitmentId");
        model = new RecruitAdvertisementCategoryModel();
        isUpdate = Boolean.FALSE;
        if (StringUtils.isNotEmpty(recruitAdvertisementCategoryId)) {
            RecruitAdvertisementCategory recruitAdvertisementCategory = service
                    .getEntiyByPK(Long.parseLong(recruitAdvertisementCategoryId));
            if (recruitAdvertisementCategory != null) {
                model = getModelFromEntity(recruitAdvertisementCategory);
                isUpdate = Boolean.TRUE;
            }
        }

    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

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

@RequestMapping
@ResponseBody/*from w  w  w  .  j  a  v a  2  s  .c o  m*/
public byte[] showImage(
        @RequestParam(value = "processDefinitionId", required = false) String processDefinitionId,
        @RequestParam(value = "processName", required = false) String processName) {
    byte[] bytes = null;
    JbpmContext jbpmContext = null;
    try {
        if (StringUtils.isNotEmpty(processDefinitionId) && StringUtils.isNumeric(processDefinitionId)) {
            bytes = JbpmProcessConfig.getImage(Long.parseLong(processDefinitionId));
        } else if (StringUtils.isNotEmpty(processName)) {
            jbpmContext = ProcessContainer.getContainer().createJbpmContext();
            ProcessDefinition processDefinition = jbpmContext.getGraphSession()
                    .findLatestProcessDefinition(processName);
            if (processDefinition != null) {
                bytes = JbpmProcessConfig.getImage(processDefinition.getId());
            }
        }
    } catch (Exception ex) {
        logger.debug(ex);
    } finally {
        Context.close(jbpmContext);
    }
    return bytes;
}

From source file:forge.limited.CustomLimited.java

/**
 * Parses the.//from w w  w. j  a v a  2 s  . c o  m
 *
 * @param dfData the df data
 * @param cubes the cubes
 * @return the custom limited
 */
public static CustomLimited parse(final List<String> dfData, final IStorage<Deck> cubes) {
    final FileSection data = FileSection.parse(dfData, ":");

    List<Pair<String, Integer>> slots = new ArrayList<Pair<String, Integer>>();
    String boosterData = data.get("Booster");
    if (StringUtils.isNotEmpty(boosterData)) {
        final String[] booster = TextUtil.splitWithParenthesis(boosterData, ',');
        for (String slotDesc : booster) {
            String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
            slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
        }
    } else
        slots = SealedProduct.Template.genericBooster.getSlots();

    final CustomLimited cd = new CustomLimited(data.get("Name"), slots);
    cd.landSetCode = data.get("LandSetCode");
    cd.numPacks = data.getInt("NumPacks");
    cd.singleton = data.getBoolean("Singleton");
    final Deck deckCube = cubes.get(data.get("DeckFile"));
    cd.cardPool = deckCube == null
            ? ItemPool.createFrom(FModel.getMagicDb().getCommonCards().getUniqueCards(), PaperCard.class)
            : deckCube.getMain();

    return cd;
}

From source file:com.inkubator.hrm.web.organisation.CompanyOwnershipFormController.java

@PostConstruct
@Override//from  www  . j  a v  a 2 s . c o  m
public void initialization() {
    super.initialization();
    try {
        String companyId = FacesUtil.getRequestParameter("companyId");
        model = new CompanyOwnershipModel();
        isUpdate = Boolean.FALSE;
        String ownershipId = FacesUtil.getRequestParameter("ownershipId");
        if (StringUtils.isNotEmpty(ownershipId)) {
            CompanyOwnership companyOwnership = companyOwnershipService
                    .getEntiyByPK(Long.parseLong(ownershipId));
            if (companyOwnership != null) {
                model = getModelFromEntity(companyOwnership);
                isUpdate = Boolean.TRUE;
            }
        }

        model.setCompanyId(Long.parseLong(companyId));
    } catch (Exception e) {
        LOGGER.error("Error", e);
    }
}

From source file:eu.europa.ec.fisheries.uvms.rules.service.bean.RulesSchedulerInitializer.java

/**
 * Method for start up Jobs of Rules Module (Deploy phase)
 *
 *  1. Setting up the scheduler timer for Rules DROOLS re-initialization - at start up -.
 *
 *//* w  w w .  j a  v a 2 s  .co m*/
@PostConstruct
public void startUpMdrInitializationProcess() {
    String schedConfigCronExpr = rulesSchedulerService.getActualSchedulerConfiguration();
    if (StringUtils.isNotEmpty(schedConfigCronExpr)) {
        try {
            rulesSchedulerService.setUpScheduler(schedConfigCronExpr);
        } catch (IllegalArgumentException ex) {
            log.error(
                    "Couldn't setUp scheduler for rules re-initialization because the cron expression from Config module is wrong! Going to setUp with the default scheduler expression : "
                            + DEFAULT_SCHED_CONFIGURATION);
            rulesSchedulerService.setUpScheduler(DEFAULT_SCHED_CONFIGURATION);
        }
    } else {
        log.warn(
                "No configuration found for Rules. Check the config module! The default schedule will be considered : "
                        + DEFAULT_SCHED_CONFIGURATION);
        rulesSchedulerService.setUpScheduler(DEFAULT_SCHED_CONFIGURATION);
    }
}

From source file:lh.api.showcase.server.api.lh.ApiRequestFactoryLhAbstract.java

@Override
public URI getRequestUri(ApiDataArea area, NameValuePair resourceNameKey,
        List<NameValuePair> subResourceNameKey, List<NameValuePair> optionKeyValue) throws URISyntaxException {

    Preconditions.checkNotNull(area);/*ww w .jav  a 2  s. c o  m*/
    Preconditions.checkNotNull(resourceNameKey);
    Preconditions.checkArgument(StringUtils.isNotEmpty(resourceNameKey.getName()));

    URIBuilder urib = new URIBuilder();
    urib.setScheme(getScheme());
    urib.setHost(getHost());

    StringBuilder sb = new StringBuilder();
    // build path
    sb.append("/");
    sb.append(getVersion());
    sb.append("/");
    // area
    sb.append(area.toString().toLowerCase());
    sb.append("/");
    // resource
    sb.append(resourceNameKey.getName());
    if (StringUtils.isNotEmpty(resourceNameKey.getValue())) {
        sb.append("/");
        sb.append(resourceNameKey.getValue());
    }
    // sub resources
    if (subResourceNameKey != null) {
        for (NameValuePair vp : subResourceNameKey) {
            if (StringUtils.isEmpty(vp.getName())) {
                continue;
            }
            sb.append("/");
            sb.append(vp.getName());
            if (StringUtils.isNotEmpty(vp.getValue())) {
                sb.append("/");
                sb.append(vp.getValue());
            }
        }
    }
    urib.setPath(sb.toString());
    // parameters
    if (optionKeyValue != null && !optionKeyValue.isEmpty()) {
        urib.setParameters(optionKeyValue);
    }
    return urib.build();
}

From source file:com.ec2box.manage.model.UserSettings.java

public void setTheme(String theme) {
    if (StringUtils.isNotEmpty(theme) && theme.split(",").length == 16) {
        this.setColors(theme.split(","));
    }//from  w w  w.  ja  v a 2s  .  c  o  m
    this.theme = theme;
}

From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionIndexerCallback.java

@Override
public void call() {
    try {/*from w w  w  .  j a v  a 2s.  c  o  m*/
        GLog.note(GWikiLogCategory.Wiki, "Start build full text index");
        String pageId = args.get("pageId");
        boolean full = false;
        if (StringUtils.equals(args.get("full"), "true") == true) {
            full = true;
        }
        if (StringUtils.isNotEmpty(pageId) == true) {
            List<GWikiElementInfo> eil = new ArrayList<GWikiElementInfo>();
            GWikiElementInfo ei = wikiContext.getWikiWeb().findElementInfo(pageId);
            if (ei != null) {
                eil.add(ei);
            }
            rebuildIndex(wikiContext, eil, full);
        } else {
            rebuildIndex(wikiContext, wikiContext.getWikiWeb().getElementInfos(), full);
        }
        GLog.note(GWikiLogCategory.Wiki, "Finished build full text index");
    } catch (Exception ex) {
        GWikiLog.warn("Job failed: " + SearchExpressionIndexerCallback.class.getName() + "; " + ex.getMessage(),
                ex);

    }
}

From source file:com.glaf.activiti.executionlistener.factory.ExecutionListenerTypes.java

static Map<String, Class<?>> initializeExecutionListenerTypes() {
    Map<String, Class<?>> types = new java.util.HashMap<String, Class<?>>();
    String resource = SystemProperties.getString("activiti.executionListeners");
    if (StringUtils.isEmpty(resource)) {
        resource = DEFAULT_CONFIG;//from  w w w  .j a v  a 2s .  c o  m
    }
    if (StringUtils.isNotEmpty(resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element executionListenersElement = XmlUtils.parseXmlInputStream(actionTypesStream)
                .getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(executionListenersElement,
                "executionListeners");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    String ext_resource = CustomProperties.getString("activiti.executionListeners");
    if (StringUtils.isNotEmpty(ext_resource)) {
        InputStream actionTypesStream = PropertiesUtils.getInputStream(resource);
        Element executionListenersElement = XmlUtils.parseXmlInputStream(actionTypesStream)
                .getDocumentElement();
        Iterator<?> nodeTypeIterator = XmlUtils.elementIterator(executionListenersElement, "executionListener");
        while (nodeTypeIterator.hasNext()) {
            Element nodeTypeElement = (Element) nodeTypeIterator.next();
            String elementTag = nodeTypeElement.getAttribute("element");
            String className = nodeTypeElement.getAttribute("class");
            try {
                Class<?> clazz = com.glaf.core.util.ClassUtils.loadClass(className);
                types.put(elementTag, clazz);
            } catch (Exception ex) {
                if (LogUtils.isDebug()) {
                    ex.printStackTrace();
                }
                logger.error("node '" + elementTag + "' will not be available. class '" + className
                        + "' couldn't be loaded");
            }
        }
    }

    return types;
}

From source file:com.keybox.manage.db.SystemDB.java

/**
 * method to do order by based on the sorted set object for systems for user
 *
 * @param sortedSet sorted set object// ww w  .j a v  a  2 s.  c o  m
 * @param userId    user id
 * @return sortedSet with list of host systems
 */
public static SortedSet getUserSystemSet(SortedSet sortedSet, Long userId) {
    List<HostSystem> hostSystemList = new ArrayList<>();

    String orderBy = "";
    if (sortedSet.getOrderByField() != null && !sortedSet.getOrderByField().trim().equals("")) {
        orderBy = "order by " + sortedSet.getOrderByField() + " " + sortedSet.getOrderByDirection();
    }
    String sql = "select * from system where id in (select distinct system_id from  system_map m, user_map um where m.profile_id=um.profile_id and um.user_id=? ";
    //if profile id exists add to statement
    sql += StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID)) ? " and um.profile_id=? "
            : "";
    sql += ") " + orderBy;

    //get user for auth token
    Connection con = null;
    try {
        con = DBUtils.getConn();
        PreparedStatement stmt = con.prepareStatement(sql);
        stmt.setLong(1, userId);
        //filter by profile id if exists
        if (StringUtils.isNotEmpty(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID))) {
            stmt.setLong(2, Long.valueOf(sortedSet.getFilterMap().get(FILTER_BY_PROFILE_ID)));
        }

        ResultSet rs = stmt.executeQuery();

        while (rs.next()) {
            HostSystem hostSystem = new HostSystem();
            hostSystem.setId(rs.getLong("id"));
            hostSystem.setDisplayNm(rs.getString(DISPLAY_NM));
            hostSystem.setUser(rs.getString("user"));
            hostSystem.setHost(rs.getString("host"));
            hostSystem.setPort(rs.getInt("port"));
            hostSystem.setAuthorizedKeys(rs.getString(AUTHORIZED_KEYS));
            hostSystem.setStatusCd(rs.getString(STATUS_CD));
            hostSystemList.add(hostSystem);
        }
        DBUtils.closeRs(rs);
        DBUtils.closeStmt(stmt);

    } catch (Exception e) {
        log.error(e.toString(), e);
    }
    DBUtils.closeConn(con);

    sortedSet.setItemList(hostSystemList);
    return sortedSet;

}