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:com.mxhero.plugin.cloudstorage.onedrive.api.Application.java

/**
 * Validate.
 */
public void validate() {
    Validate.notEmpty(clientId, "clientId at least must be present");
}

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

/**
 * Sends the provided {@link Message Message(s)} to the provided
 * {@link Player}.//  w  w w. j  a v  a  2s. c  om
 *
 * @param to       the player to whom we will send the message(s)
 * @param messages the message(s) to send
 *
 * @see Player#sendMessage(String)
 */
public static void sendMessage(final Player to, final Message... messages) {
    Validate.notNull(to, "The 'to' argument should not be null");
    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.sendMessage(to, mojangsons);
}

From source file:edu.snu.leader.spatial.builder.PersonalityAgentBuilder.java

/**
 * Initializes the builder//from ww  w.jav a2 s  .c o m
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.spatial.builder.AbstractAgentBuilder#initialize(edu.snu.leader.spatial.SimulationState)
 */
@Override
public void initialize(SimulationState simState) {
    _LOG.trace("Entering initialize( simState )");

    // Call the superclass implementation
    super.initialize(simState);

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

    // Get the initial personality value
    String initialPersonalityStr = props.getProperty(_INITIAL_PERSONALITY_KEY);
    Validate.notEmpty(initialPersonalityStr,
            "Initial personality (key=[" + _INITIAL_PERSONALITY_KEY + "]) may not be empty");
    _initialPersonality = Float.parseFloat(initialPersonalityStr);
    _LOG.info("Using _initialPersonality=[" + _initialPersonality + "]");

    // Get the communication type
    String commTypeStr = props.getProperty(_COMMUNICATION_TYPE_KEY);
    Validate.notEmpty(commTypeStr,
            "Communication type (key=[" + _COMMUNICATION_TYPE_KEY + "]) may not be empty");
    _communicationType = AgentCommunicationType.valueOf(commTypeStr.toUpperCase());
    _LOG.info("Using _communicationType=[" + _communicationType + "]");

    // Load and instantiate the initiation movement behavior
    String inititateMovementBehaviorClassName = props.getProperty(_INITIATE_MOVEMENT_BEHAVIOR_CLASS);
    Validate.notEmpty(inititateMovementBehaviorClassName, "Initiate movement behavior class (key=["
            + _INITIATE_MOVEMENT_BEHAVIOR_CLASS + "]) may not be empty");
    _initiateMovementBehavior = (MovementBehavior) MiscUtils
            .loadAndInstantiate(inititateMovementBehaviorClassName, "Initiation movement behavior");
    _LOG.info("Using inititateMovementBehaviorClassName=[" + inititateMovementBehaviorClassName + "]");

    // Load and instantiate the follow movement behavior
    String followMovementBehaviorClassName = props.getProperty(_FOLLOW_MOVEMENT_BEHAVIOR_CLASS);
    Validate.notEmpty(followMovementBehaviorClassName,
            "Follow movement behavior class (key=[" + _FOLLOW_MOVEMENT_BEHAVIOR_CLASS + "]) may not be empty");
    _followMovementBehavior = (MovementBehavior) MiscUtils.loadAndInstantiate(followMovementBehaviorClassName,
            "Follow movement behavior");
    _LOG.info("Using followMovementBehaviorClassName=[" + followMovementBehaviorClassName + "]");

    // Load and instantiate the cancel movement behavior
    String cancelMovementBehaviorClassName = props.getProperty(_CANCEL_MOVEMENT_BEHAVIOR_CLASS);
    Validate.notEmpty(cancelMovementBehaviorClassName,
            "Cancel movement behavior class (key=[" + _CANCEL_MOVEMENT_BEHAVIOR_CLASS + "]) may not be empty");
    _cancelMovementBehavior = (MovementBehavior) MiscUtils.loadAndInstantiate(cancelMovementBehaviorClassName,
            "Cancel movement behavior");
    _LOG.info("Using cancelMovementBehaviorClassName=[" + cancelMovementBehaviorClassName + "]");

    // Load and instantiate the decision probability calculator
    String decisionProbCalcClassName = props.getProperty(_DECISION_PROBABILITY_CALC_CLASS);
    Validate.notEmpty(decisionProbCalcClassName,
            "Decision probability class (key=[" + _DECISION_PROBABILITY_CALC_CLASS + "]) may not be empty");
    _calculator = (DecisionProbabilityCalculator) MiscUtils.loadAndInstantiate(decisionProbCalcClassName,
            "Decision probability calculator");
    _LOG.info("Using decisionProbCalcClassName=[" + decisionProbCalcClassName + "]");
    _calculator.initialize(simState);

    // Get the cancel threshold
    String cancelThresholdStr = props.getProperty(_CANCEL_THRESHOLD_KEY);
    Validate.notEmpty(cancelThresholdStr,
            "Cancel threshold (key=[" + _CANCEL_THRESHOLD_KEY + "]) may not be empty");
    _cancelThreshold = Float.parseFloat(cancelThresholdStr);
    _LOG.info("Using _cancelThreshold=[" + _cancelThreshold + "]");

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

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

private void sendRequestToIDP(LogoutState t) throws SamlServiceException {
    log.debug("LogoutStateProcessingFilter.sendRequestToIDP is called");
    try {/*  w w  w  .ja v a2  s. co  m*/
        String sessionId = t.getSessionId();
        Validate.notEmpty(sessionId, "sessionId");
        SessionManager sessionManager = t.getSessionManager();
        Validate.notNull(sessionManager, "sessionManager");

        Session session = sessionManager.get(sessionId);

        Validate.isTrue(session.isUsingExtIDP(), "Not expected to call sendRequestToIDP!");

        IDPConfig extIDPConfig = session.getExtIDPUsed();
        Validate.notNull(extIDPConfig, "extIDPConfig");
        String spAlias = t.getIdmAccessor().getTenant();
        Validate.notEmpty(spAlias, "spAlias");

        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");

        /*
         * Skip if the slo request was sent from external idp itself. This could happen this lotus instance
         * is one of multiple SP participated in the external IDP session.
         */
        if (extIDPConfiguration.getEntityID().equals(t.getIssuerValue()))
            return;

        SloRequestSettings extSLORequestSettings = new SloRequestSettings(spAlias, idpAlias, true,
                session.getPrincipalId().getUPN(), //subject
                OasisNames.IDENTITY_FORMAT_UPN, session.getExtIDPSessionID(), null);

        LogoutProcessorImpl logoutProcessorImpl = (LogoutProcessorImpl) getSloRequestSender()
                .getLogoutProcessor();
        logoutProcessorImpl.setLogoutState(t);

        String redirectUrl = getSloRequestSender().getRequestUrl(extSLORequestSettings);

        if (SamlUtils.isIdpSupportSLO(metadataSettings, extSLORequestSettings)) {
            Validate.notEmpty(redirectUrl, "redirectUrl");
            t.getResponse().sendRedirect(redirectUrl);
        } else {
            log.warn(
                    String.format("SLO end point does not exist for external IDP: %s, SLO request is not sent.",
                            extSLORequestSettings.getIDPAlias()));
        }
    } catch (Exception e) {
        // failed to authenticate with via proxying.
        log.debug("Caught exception in proxying logout request to external IDP: {}", e.getMessage());
        throw new SamlServiceException("Caught error in proxying logout request to external IDP:", e);
    }

}

From source file:com.evolveum.midpoint.repo.sql.data.common.container.RCertCaseReference.java

public static RCertCaseReference jaxbRefToRepo(ObjectReferenceType reference, PrismContext prismContext,
        RAccessCertificationCase owner, RCReferenceOwner refOwner) {
    if (reference == null) {
        return null;
    }/*from w  w w  .j ava2  s . co m*/
    Validate.notNull(owner, "Owner of reference must not be null.");
    Validate.notNull(refOwner, "Reference owner of reference must not be null.");
    Validate.notEmpty(reference.getOid(), "Target oid reference must not be null.");

    RCertCaseReference repoRef = new RCertCaseReference();
    repoRef.setReferenceType(refOwner);
    repoRef.setOwner(owner);
    RCertCaseReference.copyFromJAXB(reference, repoRef, prismContext);
    //        repoRef.setTargetName(RPolyString.toRepo(reference.asReferenceValue().getTargetName()));

    return repoRef;
}

From source file:ar.com.zauber.commons.spring.secrets.SQLSecretMap.java

/**
 * Creates the SQLSecretMap./*w w w . j a va 2  s  . c om*/
 *
 * @param secretGeneartor see AbstractSecretMap
 * @param expirationDatePolicy see AbstractSecretMap
 * @param expirationDateValidator see AbstractSecretMap
 * 
 * @param table sql table name
 * @param template spring jdbc template used to do the queries
 * @param mapper sql mapper
 */
public SQLSecretMap(final SecretGenerator secretGeneartor, final ExpirationDatePolicy expirationDatePolicy,
        final ExpirationDateValidator expirationDateValidator, final String table, final JdbcTemplate template,
        final Mapper mapper) {
    super(secretGeneartor, expirationDatePolicy, expirationDateValidator);

    Validate.notEmpty(table, "table");
    Validate.notNull(template, "template");
    Validate.notNull(mapper, "mapper");

    this.table = table;
    this.template = template;
    this.mapper = mapper;

    unregisterCmdSQL = getUnregisterCommandSQL();
}

From source file:ch.algotrader.dao.PositionDaoImpl.java

@Override
public List<Position> findOpenPositionsByStrategyAndMaxDate(String strategyName, Date maxDate) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notNull(maxDate, "maxDate is null");

    return find("Position.findOpenPositionsByStrategyAndMaxDate", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("maxDate", maxDate));
}

From source file:com.griddynamics.deming.ecommerce.api.endpoint.catalog.CatalogManagerEndpoint.java

@GET
@Path("export")
@Produces(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes(value = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public SimpleCatalogWrapper exportCatalog(@Context HttpServletRequest request) {
    List<Category> categories = catalogService.findCategoriesByName("Root");

    Validate.notEmpty(categories, "Root category not found.");
    Validate.isTrue(categories.size() == 1, "Root category isn't unique category.");

    Category catalog = categories.get(0);

    SimpleCatalogWrapper wrapper = (SimpleCatalogWrapper) context.getBean(SimpleCatalogWrapper.class.getName());
    wrapper.wrapDetails(catalog, request);
    return wrapper;
}

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

/**
 * @param tenant    none null.//from  w ww .j a  v a  2  s. co m
 * @param response  none null.
 * @param locale    none null.
 * @param relayState  optional
 * @param reqState    optional.
 * @param authMethod  required if reqState == null
 * @param sessionId    required if reqState == null
 * @param pId          required if reqState == null
 * @param messageSrc   none null.
 * @param sessionMgr   none null.
 */
public SAMLAuthnResponseSender(String tenant, HttpServletResponse response, Locale locale, String relayState,
        AuthnRequestState reqState, AuthnMethod authMethod, String sessionId, PrincipalId pId,
        MessageSource messageSrc, SessionManager sessionMgr) {

    Validate.notEmpty(tenant, "tenant");
    Validate.notNull(response, "response obj for service provider");
    Validate.notNull(sessionMgr, "SessionManager");
    Validate.notNull(messageSrc, "messageSrc");
    Validate.notNull(locale, "locale");

    this.response = response;
    this.locale = locale;
    this.idmAccessor = new DefaultIdmAccessorFactory().getIdmAccessor();
    idmAccessor.setTenant(tenant);
    this.relayState = relayState;
    this.messageSource = messageSrc;
    this.sessionManager = sessionMgr;

    this.authnMethod = (authMethod == null) ? reqState.getAuthnMethod() : authMethod;
    this.sessionId = (sessionId == null) ? reqState.getSessionId() : sessionId;
    this.principalId = (pId == null) ? reqState.getPrincipalId() : pId;

    if (reqState != null) {
        //SP initiated
        this.identityFormat = reqState.getIdentityFormat();
        this.reguestStartTime = reqState.getStartTime();
        AuthnRequest authnReq = reqState.getAuthnRequest();
        this.inResponseTo = authnReq == null ? null : authnReq.getID();
        this.isRenewable = reqState.isRenewable();
        this.isDelegable = reqState.isDelegable();
        this.validationResult = reqState.getValidationResult();
        this.kerbAuthnType = reqState.getKerbAuthnType();
    } else {
        //External IDP_Initiated
        this.identityFormat = OasisNames.IDENTITY_FORMAT_UPN;
        this.reguestStartTime = new GregorianCalendar().getTime();
        ;
        this.inResponseTo = null;
        this.validationResult = new ValidationResult();
        this.isRenewable = false;
        this.isDelegable = true;
    }
}

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

public SqlSessionFactory getSqlSessionFactoryProject() {

    String lStrIdProject = ContextManager.getInstance().getIdProject();

    Validate.notEmpty(lStrIdProject, "There is no project in context");
    Validate.isTrue(ProjectManager.projectExists(lStrIdProject), "Project references non existent directory");

    if (mMapSqlSessionFactoryProjects.get(lStrIdProject) == null) {
        SqlSessionFactory lSqlSessionFactoryProject = buildSqlSessionFactory(getProjectDBURL(lStrIdProject));
        mMapSqlSessionFactoryProjects.put(lStrIdProject, lSqlSessionFactoryProject);
    }/*from w  ww  .j a  v a 2 s  . co  m*/

    return mMapSqlSessionFactoryProjects.get(lStrIdProject);
}