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) 

Source Link

Document

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

 Validate.notEmpty(myString); 

The message in the exception is 'The validated string is empty'.

Usage

From source file:com.netflix.simianarmy.aws.conformity.SimpleDBConformityClusterTracker.java

@Override
public Cluster getCluster(String clusterName, String region) {
    Validate.notEmpty(clusterName);
    Validate.notEmpty(region);/*from w w  w.  j  a  v  a2s  . co m*/
    StringBuilder query = new StringBuilder();
    query.append(String.format("select * from `%s` where cluster = '%s' and region = '%s'", domain, clusterName,
            region));

    LOGGER.info(String.format("Query is to get the cluster is '%s'", query));

    List<Item> items = querySimpleDBItems(query.toString());
    Validate.isTrue(items.size() <= 1);
    if (items.size() == 0) {
        LOGGER.info(String.format("Not found cluster with name %s in region %s", clusterName, region));
        return null;
    } else {
        Cluster cluster = null;
        try {
            cluster = parseCluster(items.get(0));
        } catch (Exception e) {
            // Ignore the item that cannot be parsed.
            LOGGER.error(String.format("SimpleDB item %s cannot be parsed into a cluster.", items.get(0)));
        }
        return cluster;
    }
}

From source file:com.netflix.simianarmy.client.chef.ChefClient.java

@Override
public List<String> listAttachedVolumes(String instanceId, boolean includeRoot) {
    Validate.notEmpty(instanceId);
    LOGGER.info(String.format("ChefClient doesn't support listAttachedVolumes for %s.", instanceId));
    List<String> volumeIds = new ArrayList<String>();
    return volumeIds;
}

From source file:net.iglyduck.utils.sqlbuilder.ExpressUnit.java

protected ExpressUnit join(String join, Object exp) {
    Validate.notEmpty(join);
    Validate.notNull(exp);// ww  w.  j av a  2 s  . co  m
    Validate.isTrue(!isEmpty());

    if (exp instanceof String) {
        Validate.notEmpty((String) exp);
    } else if (exp instanceof ExpressUnit) {
        Validate.isTrue(!((ExpressUnit) exp).isEmpty());
    } else {
        Validate.isTrue(false);
    }

    ExpressItem item = new ExpressItem(join).item(exp);

    tail.setNext(item);
    tail = item;

    return this;
}

From source file:com.vmware.identity.saml.DefaultSamlAuthorityFactory.java

@Override
public TokenAuthority createTokenAuthority(String tenantName) throws NoSuchIdPException, SystemException {

    Validate.notEmpty(tenantName);
    return createTokenAuthority(tenantName, getConfigExtractor(tenantName));
}

From source file:net.iglyduck.utils.sqlbuilder.TempTable.java

public TempTable order(String item) {
    Validate.notEmpty(item);

    if (orders == null) {
        orders = new ArrayList<String>();
    }/*from  ww w .j  a va 2  s .  co m*/

    orders.add(item);
    return this;
}

From source file:com.vmware.identity.idm.IDPConfig.java

/**
 * set the signing certificate chain/* w ww .  ja v a  2s  .com*/
 *
 * @param signingCertificateChain
 *            cannot be null or empty, must be a valid certificate chain
 *            with user's signing certificate first and root CA certificate
 *            last, and the chain consists of all the certificates in the
 *            list.
 * @throws ExternalIDPExtraneousCertsInCertChainException
 *             when extraneous certificates not belong to the chain found in
 *             the list
 * @throws ExternalIDPCertChainInvalidTrustedPathException
 *             when there is no trusted path found anchored at the root CA
 *             certificate.
 */
public void setSigningCertificateChain(List<X509Certificate> signingCertificateChain)
        throws ExternalIDPExtraneousCertsInCertChainException, ExternalIDPCertChainInvalidTrustedPathException

{
    Validate.notEmpty(signingCertificateChain);
    validateSingleX509CertChain(signingCertificateChain);
    this.signingCertificateChain = signingCertificateChain;
}

From source file:com.vmware.identity.saml.DefaultSamlAuthorityFactory.java

@Override
public TokenValidator createTokenValidator(String tenantName) throws NoSuchIdPException, SystemException {

    Validate.notEmpty(tenantName);
    return createTokenValidator(tenantName, getConfigExtractor(tenantName));
}

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

/**
 * Callback function at receiving a logout request from the trusted IDP.
 * This function will find corresponding lotus login session, send a slo
 *  request to each of the session participants.
 *  The client library sloconstroller will respond to slo requester when
 *   get back from this function.//from  w  ww.  j av a 2  s  . com
 *
* @param message
*             Websso message
* @param request
* @param response
*/
@Override
public void logoutRequest(Message arg0, HttpServletRequest request, HttpServletResponse response,
        String tenant) {
    Validate.notEmpty(tenant);
    //TODO.  This is used only for lotus joining extern IDP federation (with more than one SP).  Saas used case.
    // incoming logout request from the IDP, need to clean up session info on the server
    //

    //1 create a new RequestState
    LogoutState loState = new LogoutState(request, response, sessionManager, null, null);

    //2 setup validation state since this is already validated by client lib
    ValidationResult vr = new ValidationResult(arg0.getValidationResult().getResponseCode(), arg0.getStatus(),
            arg0.getSubstatus());
    loState.setValidationResult(vr);
    //3 set to logout processor
    this.setLogoutState(loState);
    this.getLogoutState().setProcessingState(ProcessingState.PARSED);
    loState.getIdmAccessor().setTenant(tenant);

    //4 Find lotus session id using ext IDP session id. Remove castle session cookie.
    Session lotusSession = findSessionIdByExtSessionId(arg0.getSessionIndex());
    if (lotusSession == null) {
        //Ignore the request and log a warning.
        logger.warn("No session found matching external session: {}", arg0.getSessionIndex());
        return;
    }
    //Now, we found the lotus session. Get loState populated with session related infor.
    loState.setSessionId(lotusSession.getId());
    loState.setIssuerValue(lotusSession.getExtIDPUsed().getEntityID());
    loState.removeResponseHeaders();

    //5 Send SLO request to each of the session participants.
    try {
        SamlServiceImpl.sendSLORequestsToOtherParticipants(tenant, loState);
    } catch (IOException e) {
        logger.error("Caught IOException in sending logout request to service providers.");
    }
}

From source file:hudson.plugins.clearcase.action.AbstractCheckoutAction.java

/**
 * Manages the re-creation of the view if needed. If something exists but not referenced correctly as a view, it will be renamed and the view will be created
 * @param workspace The job's workspace//  w  w w .  ja  v  a2 s. c  o m
 * @param viewTag The view identifier on server. Must be unique on server
 * @param viewPath The workspace relative path of the view
 * @param streamSelector The stream selector, using streamName[@pvob] format
 * @return true if a mkview has been done, false if a view existed and is reused
 * @throws IOException
 * @throws InterruptedException
 */
protected boolean cleanAndCreateViewIfNeeded(FilePath workspace, String viewTag, String viewPath,
        String streamSelector) throws IOException, InterruptedException {
    Validate.notEmpty(viewPath);
    FilePath filePath = new FilePath(workspace, viewPath);
    boolean viewPathExists = filePath.exists();
    boolean doViewCreation = true;
    if (cleartool.doesViewExist(viewTag)) {
        if (viewPathExists) {
            if (viewTag.equals(cleartool.lscurrentview(viewPath))) {
                if (useUpdate) {
                    doViewCreation = false;
                } else {
                    cleartool.rmview(viewPath);
                }
            } else {
                filePath.renameTo(getUnusedFilePath(workspace, viewPath));
                rmviewtag(viewTag);
            }
        } else {
            rmviewtag(viewTag);
        }
    } else {
        if (viewPathExists) {
            filePath.renameTo(getUnusedFilePath(workspace, viewPath));
        }
    }
    if (doViewCreation) {
        MkViewParameters params = new MkViewParameters();
        params.setType(ViewType.Snapshot);
        params.setViewPath(viewPath);
        params.setViewTag(viewTag);
        params.setStreamSelector(streamSelector);
        params.setViewStorage(viewStorage);
        cleartool.mkview(params);
    }
    return doViewCreation;
}

From source file:com.lpm.fanger.commons.util.Reflections.java

/**
 * ?, ?DeclaredField, ?./*from  w  w  w  . ja v  a  2s .c  o m*/
 * 
 * ?Object?, null.
 */
public static Field getAccessibleField(final Object obj, final String fieldName) {
    Validate.notNull(obj, "object can't be null");
    Validate.notNull(fieldName, "method can't be null");
    Validate.notEmpty(fieldName);
    for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass
            .getSuperclass()) {
        try {
            Field field = superClass.getDeclaredField(fieldName);
            makeAccessible(field);
            return field;
        } catch (NoSuchFieldException e) {//NOSONAR
            // Field??,?
            continue;// new add
        }
    }
    return null;
}