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:net.jadler.JadlerMocker.java

/**
 * Adds a default header to be added to every stub http response.
 * @param name header name (cannot be empty)
 * @param value header value (cannot be <tt>null</tt>)
 *//* w  ww .j a  va  2s  .c o m*/
public void addDefaultHeader(final String name, final String value) {
    Validate.notEmpty(name, "header name cannot be empty");
    Validate.notNull("header value cannot be null, use an empty string instead");
    this.checkConfigurable();
    this.defaultHeaders.put(name, value);
}

From source file:com.eharmony.services.swagger.resource.DashboardRepositoryResource.java

/**
 * Validates required fields on the dashboard instance.
 *
 * @param dashboard dashboard to validate
 *///from ww w .j  av a2s . c  om
private void validateDashboard(Dashboard dashboard) {
    Validate.notEmpty(dashboard.getName(), "Name is required");
    Validate.notEmpty(dashboard.getId(), "ID is required");
    Validate.notEmpty(dashboard.getDescription(), "Description is required");
    Validate.notEmpty(dashboard.getDocumentationIds(), "At least one documentation ID is required");
}

From source file:com.common.poi.excel.util.Reflections.java

/**
 * ?, ?DeclaredMethod,?./* ww  w  . ja va 2 s.  c  o  m*/
 * ?Object?, null.
 * ????
 * 
 * ?. ?Method,?Method.invoke(Object obj, Object... args)
 */
public static Method getAccessibleMethodByName(final Object obj, final String methodName) {
    Validate.notNull(obj, "object can't be null");
    Validate.notEmpty(methodName, "methodName can't be blank");

    for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType
            .getSuperclass()) {
        Method[] methods = searchType.getDeclaredMethods();
        for (Method method : methods) {
            if (method.getName().equals(methodName)) {
                makeAccessible(method);
                return method;
            }
        }
    }
    return null;
}

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

/**
 * {@inheritDoc}/*from   w ww  . j  a v  a 2  s  .  c  o m*/
 */
@Override
public Security getSecurityByConid(final String conid) {

    Validate.notEmpty(conid, "Con id is empty");

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

}

From source file:com.firstdata.globalgatewaye4.CheckRequest.java

/**
 * @param authorization_num {@link #String} value of the authorization number. 
 * <p>Required for the following {@link #TransactionType}s:</p>
 * <ul>//ww  w. j  av a2s .c om
 * <li>{@link TransactionType#Void}</li>
 * <li>{@link TransactionType#PreAuthorizationCompletion}</li>
 * <li>{@link TransactionType#TaggedRefund}</li>
 * <li>{@link TransactionType#TaggedVoid}</li> 
 * </ul> 
 * @return {@link #CheckRequest}
 */
public CheckRequest authorization_num(String authorization_num) {
    Validate.notEmpty(authorization_num, "authorization_num cannot be empty.");
    this.authorization_num = authorization_num;
    return this;
}

From source file:gtu._work.ui.StringArrayMakerUI.java

private void jButton1ActionPerformed(ActionEvent evt) {
    try {/*from   w  w w.jav  a2s.  c  o m*/
        DefaultListModel model = JListUtil.createModel();
        String text = ClipboardUtil.getInstance().getContents();
        Validate.notEmpty(text, "");
        StringBuilder pattern = new StringBuilder();
        if (jCheckBox1.isSelected()) {
            pattern.append("\n");
        }
        if (jCheckBox2.isSelected()) {
            pattern.append("\t");
        }
        StringTokenizer tok = new StringTokenizer(text, pattern.toString());
        while (tok.hasMoreElements()) {
            String val = (String) tok.nextElement();
            model.addElement(val);
        }
        jList1.setModel(model);
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:com.vmware.identity.proxyservice.LogoutProcessorImpl.java

/**
 *
* @param sessionIndex/*from   w  w  w  . ja v a  2  s .c  o m*/
*             Websso message
* @return null or websso session string
 */
private Session findSessionIdByExtSessionId(String extSessionIndex) {
    Validate.notNull(extSessionIndex, "extSessionIndex");
    Validate.notNull(logoutState, "logoutState");

    SessionManager sessionManager = logoutState.getSessionManager();

    Validate.notNull(sessionManager, "sessionManager");
    Collection<Session> sessions = sessionManager.getAll();

    Validate.notEmpty(sessions, "sessions");

    Session localSessionToLogout = null;

    for (Session localSession : sessions) {
        if (localSession.getExtIDPSessionID().equals(extSessionIndex))
            localSessionToLogout = localSession;
        else {
            logger.debug("Session matching hit miss: session= {}", localSession.toString());
        }
    }

    if (localSessionToLogout != null) {
        logger.debug("Found a session requested in external IDP SLO request {}",
                localSessionToLogout.toString());
        return localSessionToLogout;
    }
    return null;
}

From source file:edu.snu.leader.spatial.trait.StandardUpdatePersonalityTrait.java

/**
 * Initializes the trait//w w w .  ja  v  a 2s.  c  o m
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.spatial.PersonalityTrait#initialize(edu.snu.leader.spatial.SimulationState, edu.snu.leader.spatial.Agent)
 */
@Override
public void initialize(SimulationState simState, Agent agent) {
    _LOG.trace("Entering initialize( simState, agent )");

    // Save the simulation state
    Validate.notNull(simState, "Simulation state may not be null");
    _simState = simState;

    // Save the agent
    Validate.notNull(agent, "Agent may not be null");
    _agent = agent;

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

    // 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 + "]");

    // Validate the initial personality
    if (_minPersonality > _personality) {
        _LOG.warn("Initial personality is less than the minimum min=[" + _minPersonality + "] > initial=["
                + _personality + "]");
        _personality = _minPersonality;
    } else if (_maxPersonality < _personality) {
        _LOG.warn("Initial personality is greater than the maximum min=[" + _maxPersonality + "] < initial=["
                + _personality + "]");
        _personality = _maxPersonality;
    }

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

From source file:com.vmware.identity.samlservice.impl.AuthnRequestStateExternalAuthenticationFilter.java

@Override
public void authenticate(AuthnRequestState t) throws SamlServiceException {
    log.debug("AuthnRequestStateExternalAuthenticationFilter.authenticate is called");
    Validate.isTrue(t.isProxying(), "Not expected to use AuthnRequestStateExternalAuthenticationFilter!");
    try {//from   w w  w  . j a  va 2  s  .  c  o m
        IDPConfig extIDPConfig = t.getExtIDPToUse();
        Validate.notNull(extIDPConfig, "extIDPConfig");
        String spAlias = t.getIdmAccessor().getTenant();
        Validate.notEmpty(spAlias, "spAlias");

        t.setAuthnMethod(null);
        if (null == metadataSettings.getIDPConfigurationByEntityID(extIDPConfig.getEntityID())
                || null == metadataSettings.getSPConfiguration(spAlias)) {
            SamlServiceImpl.initMetadataSettings(metadataSettings, extIDPConfig, t.getIdmAccessor());
        }

        IDPConfiguration extIDPConfiguration = metadataSettings
                .getIDPConfigurationByEntityID(extIDPConfig.getEntityID());
        Validate.notNull(extIDPConfiguration, "extIDPConfiguration");

        String idpAlias = extIDPConfiguration.getAlias();
        Validate.notEmpty(idpAlias, "idpAlias");

        SPConfiguration spConfig = metadataSettings.getSPConfiguration(spAlias);
        Validate.notNull(spConfig,
                "VMWareSSO-as-SP role metadata was missing in client lib \"metadataSettins\"");
        String acsUrl = spConfig.getAssertionConsumerServices().get(0).getLocation();

        SsoRequestSettings extSSORequestSetting = new SsoRequestSettings(spAlias, idpAlias, true,
                OasisNames.IDENTITY_FORMAT_UPN, true, //allowProxy
                false, // force authentication
                false, // passive mode
                null, // ACSIndex
                acsUrl, null //relayState
        );
        //ADFS specific settings
        extSSORequestSetting.setAllowScopingElement(false);
        extSSORequestSetting.setAllowAllowCreateInNameIDPolicy(false);
        extSSORequestSetting.setAllowSPNameQualifierInNameIDPolicy(false);
        extSSORequestSetting.setAllowRequestAuthnContext(false);

        //set proxy count.  We should set this according to spec.
        // But ADFS does not seems to support Scoping in authnrequest
        extSSORequestSetting.setProxyCount(this.getExtRequestProxyCount(t));

        LogonProcessorImpl logonProcessorImpl = (LogonProcessorImpl) getSsoRequestSender().getLogonProcessor();
        logonProcessorImpl.setRequestState(t);
        String redirectUrl = getSsoRequestSender().getRequestUrl(extSSORequestSetting);

        if (t.getTenantIDPSelectHeader() != null) {
            t.getResponse().addHeader(Shared.IDP_SELECTION_REDIRECT_URL, redirectUrl);
        } else {
            t.getResponse().sendRedirect(redirectUrl);
        }
    } catch (Exception e) {
        // failed to authenticate with via proxying.
        log.warn("Caught exception in authenticate via external IDP: {}", e.getMessage());
        ValidationResult vr = new ValidationResult(OasisNames.RESPONDER,
                "ExternalIDPAuthentication invocation failure.");
        t.setValidationResult(vr);
        throw new SamlServiceException(e);
    }
}

From source file:com.evolveum.midpoint.schema.util.ObjectTypeUtil.java

public static ObjectReferenceType createObjectRef(String oid, PolyStringType name, ObjectTypes type) {
    Validate.notEmpty(oid, "Oid must not be null or empty.");
    Validate.notNull(type, "Object type must not be null.");

    ObjectReferenceType reference = new ObjectReferenceType();
    reference.setType(type.getTypeQName());
    reference.setOid(oid);/*from  w  ww  .j a  va 2  s. c  om*/
    reference.setTargetName(name);

    return reference;
}