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.AbstractRequestMatching.java

/**
 * {@inheritDoc}//from w w  w .j  a  v  a2s .  com
 */
@Override
public T havingHeader(final String name, final Matcher<? super List<String>> predicate) {
    Validate.notEmpty(name, "name cannot be empty");
    Validate.notNull(predicate, "predicate cannot be null");

    return that(requestHeader(name, predicate));
}

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

@Override
public List<Position> findOpenPositionsByStrategyTypeAndUnderlyingType(String strategyName,
        Class<? extends Security> type, Class<? extends Security> underlyingType) {

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

    return findCaching("Position.findOpenPositionsByStrategyTypeAndUnderlyingType", QueryType.BY_NAME,
            new NamedParam("strategyName", strategyName), new NamedParam("type", type.getSimpleName()),
            new NamedParam("underlyingType", underlyingType.getSimpleName()));
}

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

/**
 * ?, ?DeclaredMethod,?./*from   w  w w  .  j  a  v  a  2s.  co  m*/
 * ?Object?, null.
 * ???+?
 * 
 * ?. ?Method,?Method.invoke(Object obj, Object... args)
 */
public static Method getAccessibleMethod(final Object obj, final String methodName,
        final Class<?>... parameterTypes) {
    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()) {
        try {
            Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
            makeAccessible(method);
            return method;
        } catch (NoSuchMethodException e) {
            // Method??,?
            continue;// new add
        }
    }
    return null;
}

From source file:com.hp.autonomy.aci.content.fieldtext.Specifier.java

/**
 * Creates a new specifier. Colons in field names will be converted to underscores.
 *
 * @param operator The fieldtext operator for the specifier.
 * @param fields An <tt>Iterable</tt> of field names.
 * @param values An <tt>Iterable</tt> of field values.
 *//*  ww  w  .j  a  v a 2s .  co  m*/
public Specifier(final String operator, final Iterable<? extends String> fields,
        final Iterable<? extends String> values) {
    Validate.isTrue(StringUtils.isNotBlank(operator), "Operator must not be blank");
    Validate.notNull(fields, "Fields must not be null");
    Validate.notNull(values, "Values must not be null");

    this.fields = Collections.unmodifiableList(resolveFields(fields));

    Validate.notEmpty(this.fields, "No valid fields were specified");

    OPERATOR = operator.trim().toUpperCase(Locale.ENGLISH).intern();

    this.values = Collections.unmodifiableList(resolveValues(values));
}

From source file:gtu.db.sqlMaker.DbSqlCreaterUI.java

private void executeBtnActionPerformed(ActionEvent evt) {
    try {//w w  w  . j a  v  a  2s  .c o m
        String url = urlText.getText();
        String username = usernameText.getText();
        String password = passwordText.getText();
        String tablename = tablenameText.getText();
        Validate.notEmpty(url, "url");
        Validate.notEmpty(username, "username");
        Validate.notEmpty(password, "password");
        Validate.notEmpty(tablename, "tablename");
        DbSqlCreater janna = new DbSqlCreater(//
                "com.microsoft.sqlserver.jdbc.SQLServerDriver", url, username, password);
        janna.execute(tablename);
        JCommonUtil._jOptionPane_showMessageDialog_info(tablename + "?");
    } catch (Exception ex) {
        JCommonUtil.handleException(ex);
    }
}

From source file:io.cloudslang.orchestrator.services.ExecutionStateServiceImpl.java

private void validateBranchId(String branchId) {
    Validate.notEmpty(StringUtils.trim(branchId), "branchId cannot be null or empty");
}

From source file:com.evolveum.midpoint.web.component.data.TablePanel.java

public void setTableCssClass(String cssClass) {
    Validate.notEmpty(cssClass, "Css class must not be null or empty.");

    DataTable table = getDataTable();/*from  www .  jav a2s.  com*/
    table.add(new AttributeAppender("class", new Model(cssClass), " "));
}

From source file:com.autonomy.aci.client.services.impl.AciServiceImpl.java

/**
 * Executes an ACI action and processes the response with the supplied <tt>Processor</tt>.
 * @param serverDetails The connection details of the ACI Server to execute the action on
 * @param parameters    The parameters to use with the ACI command. This <strong>should</strong> include an {@code
 *                      Action=&lt;command&gt;} parameter
 * @param processor     The <tt>Processor</tt> to use for converting the response stream into an object
 * @return The ACI response encoded as an object of type <tt>T</tt>
 * @throws AciServiceException      If an error occurred during the communication with the ACI Server, processing the
 *                                  response or if the response contained an error
 * @throws IllegalArgumentException If <tt>serverDetails</tt> is <tt>null</tt>, or the <tt>parameters</tt> is
 *                                  <tt>null</tt>, empty or missing an action parameter. Will also be thrown in the
 *                                  <tt>processor</tt> is null.
 *///from   w ww  . j ava 2s .  c  o  m
@Override
public <T> T executeAction(final AciServerDetails serverDetails,
        final Set<? extends ActionParameter<?>> parameters, final Processor<T> processor) {
    LOGGER.trace("executeAction() called...");

    // Sanity check the HttpClient...
    Validate.notNull(aciHttpClient, "An AciHttpClient implementation must be set before calling this method.");

    // Sanity check the method parameters...
    Validate.notNull(serverDetails, "ACI Server connection details must be set before calling this method.");
    Validate.notEmpty(parameters, "The parameter set must not be null or empty.");
    Validate.isTrue(parameters.contains(TEST_ACTION_PARAMETER),
            "The parameter set must contain an action=xxx parameter.");
    Validate.notNull(processor, "The processor must not be null.");

    // This is so we can close the response and return the connection to the pool...
    AciResponseInputStream response = null;

    try {
        LOGGER.debug("Sending the ACI parameters and server details to the AciHttpClient...");

        // Execute the action and process the response...
        response = aciHttpClient.executeAction(serverDetails, parameters);
        return processor.process(response);
    } catch (final AciHttpException ahe) {
        LOGGER.trace("AciHttpException caught while executing the ACI action");
        throw new AciServiceException(ahe);
    } catch (final IOException ioe) {
        LOGGER.trace("IOException caught while executing the ACI action");
        throw new AciServiceException(ioe);
    } catch (final ProcessorException pe) {
        LOGGER.trace("ProcessorException caught while parsing ACI response");
        throw new AciServiceException(pe);
    } finally {
        // Close the response as the processor should have dealt with it...
        IOUtils.getInstance().closeQuietly(response);
    }
}

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

@Override
public void authenticationError(Message arg0, Locale locale, String tenant, HttpServletRequest request,
        HttpServletResponse response) {//  www .jav a 2s  .  c  o  m

    Validate.notNull(arg0, "arg0");
    Validate.notNull(response, "response");
    try {

        ValidationResult vrExtIdpSsoResponse = retrieveValidationResult(arg0);

        //retrieve current VR
        if (!arg0.isIdpInitiated() && requestState != null) {
            ValidationResult vr = requestState.getValidationResult();
            if (!(null != vr && !vr.isValid())) {
                requestState.setValidationResult(vrExtIdpSsoResponse);
            }
        } else {
            Validate.notEmpty(tenant, "tenant");
            Validate.notNull(locale, "locale");

        }

        //retrieve browser locale
        if (null == locale) {
            locale = requestState == null ? Locale.getDefault() : requestState.getLocale();
        }

        int responseCode = vrExtIdpSsoResponse.getResponseCode();

        //default code is  HttpServletResponse.SC_UNAUTHORIZED
        if (responseCode == HttpServletResponse.SC_OK) {
            responseCode = HttpServletResponse.SC_UNAUTHORIZED;
        }

        String message = vrExtIdpSsoResponse.getMessage(messageSource, locale);

        if (OasisNames.RESPONDER.equals(vrExtIdpSsoResponse.getStatus())) {
            message = messageSource.getMessage(ExternalIDPErrorMessageName, null, locale) + message;
        }
        response.addHeader(Shared.RESPONSE_ERROR_HEADER, Shared.encodeString(message));
        response.sendError(responseCode, message);
        log.info("External IDP responded with ERROR {} message {}", vrExtIdpSsoResponse.getResponseCode(),
                message);

    } catch (Exception e) {
        log.error("Caught unexpect exception in processing authentication error {}", e.toString());

        throw new IllegalStateException(e);
    }
}

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

/**
 * {@inheritDoc}/*from  www. jav a  2s  .com*/
 */
@Override
@ManagedOperation(description = "Manually record a Transaction")
@ManagedOperationParameters({
        @ManagedOperationParameter(name = "securityId", description = "SecurityId (for CREDIT / DEBIT / INTREST_PAID / INTREST_RECEIVED / DIVIDEND / FEES / REFUND enter 0)"),
        @ManagedOperationParameter(name = "strategyName", description = "Name of the Strategy"),
        @ManagedOperationParameter(name = "extId", description = "External transaction id (e.g. 0001f4e6.4fe7e2cb.01.01)"),
        @ManagedOperationParameter(name = "dateTime", description = "DateTime of the Transaction. Format: dd.mm.yyyy hh:mm:ss"),
        @ManagedOperationParameter(name = "quantity", description = "<html>Requested quantity: <ul> <li> BUY: pos </li> <li> SELL: neg </li> <li> EXPIRATION: pos/neg </li> <li> TRANSFER : pos/neg </li> <li> CREDIT: 1 </li> <li> INTREST_RECEIVED: 1 </li> <li> REFUND : 1 </li> <li> DIVIDEND : 1 </li> <li> DEBIT: -1 </li> <li> INTREST_PAID: -1 </li> <li> FEES: -1 </li> </ul></html>"),
        @ManagedOperationParameter(name = "price", description = "Price"),
        @ManagedOperationParameter(name = "executionCommission", description = "Execution Commission. 0 if not applicable"),
        @ManagedOperationParameter(name = "clearingCommission", description = "Clearing Commission. 0 if not applicable"),
        @ManagedOperationParameter(name = "fee", description = "fee"),
        @ManagedOperationParameter(name = "currency", description = "Currency"),
        @ManagedOperationParameter(name = "transactionType", description = "<html>Transaction type: <ul> <li> B (BUY) </li> <li> S (SELL) </li> <li> E (EXPIRATION) </li> <li> T (TRANSFER) </li> <li> C (CREDIT) </li> <li> D (DEBIT) </li> <li> IP (INTREST_PAID) </li> <li> IR (INTREST_RECEIVED) </li> <li> DI (DIVIDEND) </li> <li> F (FEES) </li> <li> RF (REFUND) </li> </ul></html>"),
        @ManagedOperationParameter(name = "accountName", description = "Account Name") })
public void recordTransaction(final long securityId, final String strategyName, final String extId,
        final String dateTime, final long quantity, final double price, final double executionCommission,
        final double clearingCommission, final double fee, final String currency, final String transactionType,
        final String accountName) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notEmpty(dateTime, "Date time is empty");
    Validate.notEmpty(transactionType, "Transaction type is empty");

    Date dateTimeObject;
    try {
        dateTimeObject = DateTimeLegacy.parseAsDateTimeGMT(dateTime);
    } catch (DateTimeParseException ex) {
        throw new ServiceException(ex);
    }
    String extIdString = !"".equals(extId) ? extId : null;
    BigDecimal priceDecimal = RoundUtil.getBigDecimal(price);
    BigDecimal executionCommissionDecimal = (executionCommission != 0)
            ? RoundUtil.getBigDecimal(executionCommission)
            : null;
    BigDecimal clearingCommissionDecimal = (clearingCommission != 0)
            ? RoundUtil.getBigDecimal(clearingCommission)
            : null;
    BigDecimal feeDecimal = (fee != 0) ? RoundUtil.getBigDecimal(fee) : null;
    Currency currencyObject = !"".equals(currency) ? Currency.valueOf(currency) : null;
    TransactionType transactionTypeObject = TransactionType.fromValue(transactionType);

    this.transactionService.createTransaction(securityId, strategyName, extIdString, dateTimeObject, quantity,
            priceDecimal, executionCommissionDecimal, clearingCommissionDecimal, feeDecimal, currencyObject,
            transactionTypeObject, accountName, null);

}