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:ar.com.zauber.garfio.config.impl.PropertiesConfiguration.java

/** @see Configuration#getRepositoryName() */
public final String getRepositoryName() {
    final String reponame = config.getProperty(GARFIO_REPO_NAME);
    Validate.notEmpty(reponame, "property " + GARFIO_REPO_NAME + " must be specified");
    return reponame;
}

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

public static void copyFromJAXB(ObjectReferenceType jaxb, RAssignmentReference repo,
        PrismContext prismContext) {//from w  w w .j  ava2s  . co  m
    Validate.notNull(repo, "Repo object must not be null.");
    Validate.notNull(jaxb, "JAXB object must not be null.");
    Validate.notEmpty(jaxb.getOid(), "Target oid must not be null.");

    repo.setType(ClassMapper.getHQLTypeForQName(jaxb.getType()));
    repo.setRelation(RUtil.qnameToString(jaxb.getRelation()));

    repo.setTargetOid(jaxb.getOid());
}

From source file:com.github.restdriver.clientdriver.SecureClientDriverFactory.java

/**
 * Create SecureClientDriver with the given configuration.
 * //from  w  ww.  j ava2  s . c  o m
 * @return the newly-created driver
 */
public SecureClientDriver build() {
    Validate.notEmpty(certAlias, "Certificate alias is not set.");
    Validate.notEmpty(password, "Password not set.");
    Validate.notNull(keyStore, "Key store is not set.");
    SecureClientDriver clientDriver = new SecureClientDriver(
            new DefaultClientDriverJettyHandler(new DefaultRequestMatcher()), port, keyStore, password,
            certAlias);
    LOGGER.debug("ClientDriver created at '" + clientDriver.getBaseUrl() + "'.");
    return clientDriver;
}

From source file:edu.snu.leader.spatial.observer.ResultsReporterSimObserver.java

/**
 * Initializes this observer//from w w  w. ja  va2  s.c o m
 *
 * @param simState The simulation state
 * @param keyPrefix Prefix for configuration property keys
 * @see edu.snu.leader.spatial.observer.AbstractSimObserver#initialize(edu.snu.leader.spatial.SimulationState, java.lang.String)
 */
@Override
public void initialize(SimulationState simState, String keyPrefix) {
    _LOG.trace("Entering initialize( simState, keyPrefix )");

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

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

    // Load the results filename
    String resultsFile = props.getProperty(_RESULTS_FILE_KEY);
    Validate.notEmpty(resultsFile, "Results file may not be empty");
    _LOG.info("Sending results to [" + resultsFile + "]");

    // Create the statistics writer
    try {
        _writer = new PrintWriter(new BufferedWriter(new FileWriter(resultsFile)));
    } catch (IOException ioe) {
        _LOG.error("Unable to open results file [" + resultsFile + "]", ioe);
        throw new RuntimeException("Unable to open results file [" + resultsFile + "]", ioe);
    }

    // Log the system properties to the stats file for future reference
    _writer.println("# Started: " + (new Date()));
    _writer.println(_SPACER);
    _writer.println("# Simulation properties");
    _writer.println(_SPACER);
    List<String> keyList = new ArrayList<String>(props.stringPropertyNames());
    Collections.sort(keyList);
    Iterator<String> iter = keyList.iterator();
    while (iter.hasNext()) {
        String key = iter.next();
        String value = props.getProperty(key);

        _writer.println("# " + key + " = " + value);
    }
    _writer.println(_SPACER);
    _writer.println();
    _writer.flush();

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

From source file:net.ripe.rpki.commons.provisioning.cms.ProvisioningCmsObjectBuilder.java

public ProvisioningCmsObject build(PrivateKey privateKey) {
    Validate.notEmpty(payloadContent, "Payload content is required");

    Validate.notNull(cmsCertificate, "cms certificate is required");
    Validate.notNull(crl, "crl is required");

    ProvisioningCmsObjectParser parser = new ProvisioningCmsObjectParser();
    parser.parseCms("n/a", generateCms(privateKey));

    ValidationResult validationResult = parser.getValidationResult();
    if (validationResult.hasFailures()) {
        List<String> failureMessages = new ArrayList<String>();
        List<ValidationCheck> failures = validationResult.getFailures(new ValidationLocation("generated.cms"));
        for (ValidationCheck check : failures) {
            failureMessages.add(check.getKey());
        }/*  ww w  . j av a 2  s.c o m*/
        Validate.isTrue(false, "Validation of generated CMS object failed with following errors: "
                + StringUtils.join(failureMessages, ","));
    }

    return parser.getProvisioningCmsObject();
}

From source file:hudson.plugins.clearcase.ClearCaseUcmSCM.java

@DataBoundConstructor
public ClearCaseUcmSCM(String stream, String loadrules, String viewTag, boolean usedynamicview,
        String viewdrive, String mkviewoptionalparam, boolean filterOutDestroySubBranchEvent, boolean useUpdate,
        boolean rmviewonrename, String excludedRegions, String multiSitePollBuffer, String overrideBranchName,
        boolean createDynView, boolean freezeCode, boolean recreateView, boolean allocateViewName,
        String viewPath, boolean useManualLoadRules, ChangeSetLevel changeset,
        ViewStorageFactory viewStorageFactory) {
    super(viewTag, mkviewoptionalparam, filterOutDestroySubBranchEvent, useUpdate, rmviewonrename,
            excludedRegions, usedynamicview, viewdrive, useManualLoadRules ? loadrules : null,
            multiSitePollBuffer, createDynView, freezeCode, recreateView, viewPath, changeset,
            viewStorageFactory);/*from w w w  .jav a2 s  . co m*/
    this.stream = shortenStreamName(stream);
    this.allocateViewName = allocateViewName;
    this.overrideBranchName = overrideBranchName;
    this.useManualLoadRules = useManualLoadRules ? useManualLoadRules : StringUtils.isNotBlank(loadrules); // Default to keep backward compat
    Validate.notEmpty(this.stream, "The stream selector cannot be empty");
}

From source file:it.gualtierotesta.gdocx.GP.java

/**
 * Set text color/*from   w w w  .j a  v  a  2s . co  m*/
 *
 * @param sColor color code as 6 char color2hex string (RRGGBB)
 * @return same GP instance
 */
@Nonnull
public GP color(@Nonnull final String sColor) {

    Validate.notEmpty(sColor, "String color not valid");

    final Color par = FACTORY.createColor();
    par.setVal(sColor);
    getRPr().setColor(par);
    return this;
}

From source file:me.pagekite.glen3b.library.bukkit.datastore.Message.java

/**
 * Sets the specified key to map to the specified value in all registered read/write {@link MessageProvider} instances.
 * @param key The key of the message to set.
 * @param value The value of the message to set.
 *//*from  ww  w .  j ava2 s  .c o  m*/
public static void setAll(String key, String value) {
    Validate.notEmpty(key, "The key cannot be null or empty.");
    Validate.notNull(value, "The message cannot be null.");

    Collection<RegisteredServiceProvider<MessageProvider>> registeredMsgs = Bukkit.getServer()
            .getServicesManager().getRegistrations(MessageProvider.class);

    for (RegisteredServiceProvider<MessageProvider> message : registeredMsgs) {
        if (!message.getProvider().isReadOnly()) {
            message.getProvider().setMessage(key, value);
        }
    }
}

From source file:ch.algotrader.dao.strategy.MeasurementDaoImpl.java

@Override
public List<Measurement> findAllMeasurementsByMinDate(String strategyName, Date minDateTime) {

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

    return findCaching("Measurement.findAllMeasurementsByMinDate", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("minDateTime", minDateTime));
}

From source file:edu.snu.leader.hidden.builder.AssertivenessAndDirectionIndividualBuilder.java

/**
 * Initializes the builder/*from   w  w w. j av a  2  s  .c om*/
 *
 * @param simState The simulation's state
 * @see edu.snu.leader.hidden.builder.AbstractIndividualBuilder#initialize(edu.snu.leader.hidden.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.getProps();

    // Get the mean assertiveness value
    String assertivenessMeanStr = props.getProperty(_ASSERT_MEAN_KEY);
    Validate.notEmpty(assertivenessMeanStr,
            "Assertiveness mean (key=" + _ASSERT_MEAN_KEY + ") may not be empty");
    _assertivenessMean = Float.parseFloat(assertivenessMeanStr);
    _LOG.info("Using _assertivenessMean=[" + _assertivenessMean + "]");

    // Get the assertiveness value standard deviation
    String assertivenessStdDevStr = props.getProperty(_ASSERT_STD_DEV_KEY);
    Validate.notEmpty(assertivenessStdDevStr,
            "Assertiveness std dev (key=" + _ASSERT_STD_DEV_KEY + ") may not be empty");
    _assertivenessStdDev = Float.parseFloat(assertivenessStdDevStr);
    _LOG.info("Using _assertivenessStdDev=[" + _assertivenessStdDev + "]");

    // Get the min assertiveness
    String minAssertivenessStr = props.getProperty(_MIN_ASSERT_KEY);
    Validate.notEmpty(minAssertivenessStr,
            "Minimum Assertiveness value (key=" + _MIN_ASSERT_KEY + ") may not be empty");
    _minAssertiveness = Float.parseFloat(minAssertivenessStr);
    _LOG.info("Using _minAssertiveness=[" + _minAssertiveness + "]");

    // Get the max assertiveness
    String maxAssertivenessStr = props.getProperty(_MAX_ASSERT_KEY);
    Validate.notEmpty(maxAssertivenessStr,
            "Maximum Assertiveness value (key=" + _MAX_ASSERT_KEY + ") may not be empty");
    _maxAssertiveness = Float.parseFloat(maxAssertivenessStr);
    _LOG.info("Using _maxAssertiveness=[" + _maxAssertiveness + "]");

    // Get the random number distribution for
    String assertivenessRNDistStr = props.getProperty(_ASSERT_RNG_DIST_KEY);
    Validate.notEmpty(assertivenessRNDistStr,
            "Random number distribution for assertiveness (key=" + _ASSERT_RNG_DIST_KEY + ") may not be empty");
    _assertivenessRNDist = RNDistribution.valueOf(assertivenessRNDistStr.toUpperCase());
    _LOG.info("Using _assertivenessRNDist=[" + _assertivenessRNDist + "]");

    // Get the mean direction value
    String directionMeanStr = props.getProperty(_DIR_MEAN_KEY);
    Validate.notEmpty(directionMeanStr, "Direction mean (key=" + _DIR_MEAN_KEY + ") may not be empty");
    _directionMean = Float.parseFloat(directionMeanStr);
    _LOG.info("Using _directionMean=[" + _directionMean + "]");

    // Get the  value standard deviation
    String directionStdDevStr = props.getProperty(_DIR_STD_DEV_KEY);
    Validate.notEmpty(directionStdDevStr, "Direction std dev (key=" + _DIR_STD_DEV_KEY + ") may not be empty");
    _directionStdDev = Float.parseFloat(directionStdDevStr);
    _LOG.info("Using _directionStdDev=[" + _directionStdDev + "]");

    // Get the min direction
    String minDirectionStr = props.getProperty(_MIN_DIR_KEY);
    Validate.notEmpty(minDirectionStr, "Minimum Direction (key=" + _MIN_DIR_KEY + ") may not be empty");
    _minDirection = Float.parseFloat(minDirectionStr);
    _LOG.info("Using _minDirection=[" + _minDirection + "]");

    // Get the max direction
    String maxDirectionStr = props.getProperty(_MAX_DIR_KEY);
    Validate.notEmpty(maxDirectionStr, "Maximum direction (key=" + _MAX_DIR_KEY + ") may not be empty");
    _maxDirection = Float.parseFloat(maxDirectionStr);
    _LOG.info("Using _maxDirection=[" + _maxDirection + "]");

    // Get the random number distribution for the direction
    String directionRNDistStr = props.getProperty(_DIR_RNG_DIST_KEY);
    Validate.notEmpty(directionRNDistStr,
            "Random number distribution for direction (key=" + _DIR_RNG_DIST_KEY + ") may not be empty");
    _directionRNDist = RNDistribution.valueOf(directionRNDistStr.toUpperCase());
    _LOG.info("Using _directionRNDist=[" + _directionRNDist + "]");

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