Example usage for org.apache.commons.lang Validate notEmpty

List of usage examples for org.apache.commons.lang Validate notEmpty

Introduction

In this page you can find the example usage for org.apache.commons.lang Validate notEmpty.

Prototype

public static void notEmpty(String string, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument String is empty (null or zero length).

 Validate.notEmpty(myString, "The string must not be empty"); 

Usage

From source file:fr.ribesg.bukkit.api.chat.Chat.java

/**
 * Broadcasts the provided {@link Message Message(s)} to
 * {@link Player Players} having the provided permission.
 *
 * @param permission a permission required to receive the message(s)
 * @param messages   the message(s) to send
 *
 * @see Server#broadcast(String, String)
 *///from   w  ww.ja  v  a  2 s .  c  o  m
public static void broadcast(final String permission, final Message... messages) {
    Validate.notEmpty(permission, "The 'permission' argument should not be null nor empty");
    Validate.notEmpty(messages, "Please provide at least one Message");
    Validate.noNullElements(messages, "The 'messages' argument should not contain null values");
    final String[] mojangsons = new String[messages.length];
    for (int i = 0; i < messages.length; i++) {
        mojangsons[i] = Chat.toMojangson(messages[i]);
    }
    Chat.broadcast(permission, mojangsons);
}

From source file:com.evolveum.midpoint.wf.impl.jobs.WfProcessInstanceShadowTaskHandler.java

private void queryProcessInstance(String id, Task task, OperationResult parentResult) {

    String taskOid = task.getOid();
    Validate.notEmpty(taskOid, "Task oid must not be null or empty (task must be persistent).");

    OperationResult result = parentResult.createSubresult(DOT_CLASS + "queryProcessInstance");

    QueryProcessCommand qpc = new QueryProcessCommand();
    qpc.setTaskOid(taskOid);/*  w w w.j  a v a2  s  .  c o m*/
    qpc.setPid(id);

    try {
        activitiInterface.midpoint2activiti(qpc, task, result);
    } catch (RuntimeException e) {
        LoggingUtils.logException(LOGGER,
                "Couldn't send a request to query a process instance to workflow management system", e);
        result.recordPartialError(
                "Couldn't send a request to query a process instance to workflow management system", e);
    }

    result.recordSuccessIfUnknown();
}

From source file:net.ripe.rpki.validator.util.TrustAnchorLocator.java

public TrustAnchorLocator(File file, String caName, URI location, String publicKeyInfo,
        List<URI> prefetchUris) {
    Validate.notEmpty(caName, "'ca.name' must be provided");
    Validate.notNull(location, "'certificate.location' must be provided");
    Validate.notEmpty(publicKeyInfo, "'public.key.info' must be provided");
    this.file = file;
    this.caName = caName;
    this.certificateLocation = location;
    this.publicKeyInfo = publicKeyInfo;
    this.prefetchUris = prefetchUris;
}

From source file:com.bibisco.dao.SqlSessionFactoryManager.java

public void cleanSqlSessionFactoryProject() {

    mLog.debug("Start cleanSqlSessionFactoryProject()");

    Validate.notEmpty(ContextManager.getInstance().getIdProject(), "There is no project in context");

    String lStrProjectId = ContextManager.getInstance().getIdProject();
    SqlSessionFactory lSqlSessionFactoryProject = mMapSqlSessionFactoryProjects.get(lStrProjectId);
    PooledDataSource lPooledDataSource = (PooledDataSource) lSqlSessionFactoryProject.getConfiguration()
            .getEnvironment().getDataSource();
    lPooledDataSource.forceCloseAll();//from  w ww  .  j a va 2  s.  co  m
    mMapSqlSessionFactoryProjects.remove(lStrProjectId);

    mLog.debug("End cleanSqlSessionFactoryProject()");
}

From source file:ch.algotrader.dao.security.SecurityDaoImpl.java

@Override
public Long findSecurityIdByIsin(String isin) {

    Validate.notEmpty(isin, "isin is empty");

    return convertId(findUniqueObject(null, "Security.findSecurityIdByIsin", QueryType.BY_NAME,
            new NamedParam("isin", isin)));
}

From source file:edu.snu.leader.hidden.personality.BystanderUpdateRulePersonalityCalculator.java

/**
 * Initializes the updater/*from  w  w  w . j  a  va 2s. com*/
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.personality.PersonalityCalculator#initialize(edu.snu.leader.hidden.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( simState )");

    // Get the properties
    Properties props = simState.getProps();

    // Get the discount value
    String discountStr = props.getProperty(_DISCOUNT_KEY);
    Validate.notEmpty(discountStr, "Personality discount (key=" + _DISCOUNT_KEY + ") may not be empty");
    _discount = Float.parseFloat(discountStr);
    _LOG.info("Using _discount=[" + _discount + "]");

    // Get the true winner discount value
    String trueWinnerDiscountStr = props.getProperty(_TRUE_WINNER_DISCOUNT_KEY);
    if (null != trueWinnerDiscountStr) {
        _trueWinnerDiscount = Float.parseFloat(trueWinnerDiscountStr);
    } else {
        _trueWinnerDiscount = _discount;
    }
    _LOG.info("Using _trueWinnerDiscount=[" + _trueWinnerDiscount + "]");

    // Get the true loser discount value
    String trueLoserDiscountStr = props.getProperty(_TRUE_LOSER_DISCOUNT_KEY);
    if (null != trueLoserDiscountStr) {
        _trueLoserDiscount = Float.parseFloat(trueLoserDiscountStr);
    } else {
        _trueLoserDiscount = _discount;
    }
    _LOG.info("Using _trueLoserDiscount=[" + _trueLoserDiscount + "]");

    // Get the bystander winner discount value
    String bystanderWinnerDiscountStr = props.getProperty(_BYSTANDER_WINNER_DISCOUNT_KEY);
    if (null != bystanderWinnerDiscountStr) {
        _bystanderWinnerDiscount = Float.parseFloat(bystanderWinnerDiscountStr);
    } else {
        _bystanderWinnerDiscount = _discount;
    }
    _LOG.info("Using _bystanderWinnerDiscount=[" + _bystanderWinnerDiscount + "]");

    // Get the bystander loser discount value
    String bystanderLoserDiscountStr = props.getProperty(_BYSTANDER_LOSER_DISCOUNT_KEY);
    if (null != bystanderLoserDiscountStr) {
        _bystanderLoserDiscount = Float.parseFloat(bystanderLoserDiscountStr);
    } else {
        _bystanderLoserDiscount = _discount;
    }
    _LOG.info("Using _bystanderLoserDiscount=[" + _bystanderLoserDiscount + "]");

    // Get the winner reward
    String winnerRewardStr = props.getProperty(_WINNER_REWARD_KEY);
    Validate.notEmpty(winnerRewardStr, "Winner reward (key=[" + _WINNER_REWARD_KEY + "]) may not be empty");
    _winnerReward = Float.parseFloat(winnerRewardStr);
    _LOG.info("Using _winnerReward=[" + _winnerReward + "]");

    // Get the loser penalty
    String loserPenaltyStr = props.getProperty(_LOSER_PENALTY_KEY);
    Validate.notEmpty(loserPenaltyStr, "Loser penalty (key=[" + _LOSER_PENALTY_KEY + "]) may not be empty");
    _loserPenalty = Float.parseFloat(loserPenaltyStr);
    _LOG.info("Using _loserPenalty=[" + _loserPenalty + "]");

    // Get the true winner effect flag
    String trueWinnerEffectStr = props.getProperty(_TRUE_WINNER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(trueWinnerEffectStr,
            "True winner effects active flag (key=[" + _TRUE_WINNER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _trueWinnerEffectActive = Boolean.parseBoolean(trueWinnerEffectStr);
    _LOG.info("Using _trueWinnerEffectActive=[" + _trueWinnerEffectActive + "]");

    // Get the true loser effect flag
    String trueLoserEffectStr = props.getProperty(_TRUE_LOSER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(trueLoserEffectStr,
            "True loser effects active flag (key=[" + _TRUE_LOSER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _trueLoserEffectActive = Boolean.parseBoolean(trueLoserEffectStr);
    _LOG.info("Using _trueLoserEffectActive=[" + _trueLoserEffectActive + "]");

    // Get the bystander winner effect flag
    String bystanderWinnerEffectStr = props.getProperty(_BYSTANDER_WINNER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(bystanderWinnerEffectStr, "Bystander winner effects active flag (key=["
            + _BYSTANDER_WINNER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _bystanderWinnerEffectActive = Boolean.parseBoolean(bystanderWinnerEffectStr);
    _LOG.info("Using _bystanderWinnerEffectActive=[" + _bystanderWinnerEffectActive + "]");

    // Get the bystander loser effect flag
    String bystanderLoserEffectStr = props.getProperty(_BYSTANDER_LOSER_EFFECTS_ACTIVE_KEY);
    Validate.notEmpty(bystanderLoserEffectStr, "Bystander loser effects active flag (key=["
            + _BYSTANDER_LOSER_EFFECTS_ACTIVE_KEY + "]) may not be empty");
    _bystanderLoserEffectActive = Boolean.parseBoolean(bystanderLoserEffectStr);
    _LOG.info("Using _bystanderLoserEffectActive=[" + _bystanderLoserEffectActive + "]");

    // Get the min personality
    String minPersonalityStr = props.getProperty(_MIN_PERSONALITY_KEY);
    Validate.notEmpty(minPersonalityStr,
            "Minimum personality value (key=" + _MIN_PERSONALITY_KEY + ") may not be empty");
    _minPersonality = Float.parseFloat(minPersonalityStr);
    _LOG.info("Using _minPersonality=[" + _minPersonality + "]");

    // Get the max personality
    String maxPersonalityStr = props.getProperty(_MAX_PERSONALITY_KEY);
    Validate.notEmpty(maxPersonalityStr,
            "Maximum personality value (key=" + _MAX_PERSONALITY_KEY + ") may not be empty");
    _maxPersonality = Float.parseFloat(maxPersonalityStr);
    _LOG.info("Using _maxPersonality=[" + _maxPersonality + "]");

    _LOG.trace("Leaving initialize( simState )");
}

From source file:com.evolveum.midpoint.wf.impl.tasks.WfProcessInstanceShadowTaskHandler.java

private void queryProcessInstance(String id, Task task, OperationResult parentResult) {

    String taskOid = task.getOid();
    Validate.notEmpty(taskOid, "Task oid must not be null or empty (task must be persistent).");

    OperationResult result = parentResult.createSubresult(DOT_CLASS + "queryProcessInstance");

    QueryProcessCommand qpc = new QueryProcessCommand();
    qpc.setTaskOid(taskOid);//from  w w w  .j a v  a  2  s  . com
    qpc.setPid(id);

    try {
        activitiInterface.queryActivitiProcessInstance(qpc, task, result);
    } catch (RuntimeException | ObjectNotFoundException | ObjectAlreadyExistsException | SchemaException e) {
        LoggingUtils.logUnexpectedException(LOGGER,
                "Couldn't send a request to query a process instance to workflow management system", e);
        result.recordPartialError(
                "Couldn't send a request to query a process instance to workflow management system", e);
    } finally {
        result.computeStatusIfUnknown();
    }
}

From source file:ch.algotrader.service.LookupServiceImpl.java

/**
 * {@inheritDoc}//from  w  w  w  .ja v a2 s  .c  o m
 */
@Override
public Security getSecurityByIsin(final String isin) {

    Validate.notEmpty(isin, "isin is empty");

    return this.cacheManager.findUnique(Security.class, "Security.findByIsin", QueryType.BY_NAME,
            new NamedParam("isin", isin));

}

From source file:gtu.xml.work.CacDBUI4Janna.java

private void executeBtnActionPerformed(ActionEvent evt) {
    try {/*from ww  w. j  a  va  2 s  .  c  om*/
        String tableName = (String) tableNameCombo.getSelectedItem();
        String destFileName = destFileNameText.getText();
        String dmvValue = dmvText.getText();
        File srcFile = JCommonUtil.filePathCheck(srcFileText.getText(), "xml?", "xml");
        Validate.notEmpty(tableName, "??");
        Validate.notEmpty(destFileName, "???");
        Validate.isTrue(srcFile != null && srcFile.exists(), "??!");

        DB4Janna janna = null;
        if ("cac_fcase".equals(tableName)) {
            janna = new ReadXmlToSQL_CacFcase_4Janna();
        } else if ("cac_ecase".equals(tableName)) {
            janna = new ReadXmlToSQL_CacEcase_4Janna();
        } else if ("cac_fcase_count".equals(tableName)) {
            janna = new ReadXmlToSQL_CacFcaseCourt_4Janna();
        }
        janna.execute(dmvValue, srcFile, destFileName);
        JCommonUtil._jOptionPane_showMessageDialog_info("?!");
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:com.github.mhendred.face4j.DefaultFaceClient.java

/**
 * @see {@link FaceClient#removeTags(String)}
 *///from w  w w  .j a v  a  2s .c om
@Override
public List<RemovedTag> removeTags(final String tids) throws FaceClientException, FaceServerException {
    Validate.notEmpty(tids, "Tag ids cannot be empty");

    final Parameters params = new Parameters("tids", tids);
    final String json = executePost(Api.REMOVE_TAGS, params);
    final RemoveTagResponse response = new RemoveTagResponseImpl(json);

    return response.getRemovedTags();
}