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.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java

/**
 * Should be called when user's name is changed in LR.
 *//*  ww  w. j a  v  a  2  s.  c  o m*/
public static boolean changeName(String name, String newFirstName, String newLastName, String newFullName) {

    Validate.notEmpty(name);
    Validate.notEmpty(newFirstName);
    Validate.notEmpty(newLastName);
    Validate.notEmpty(newFullName);

    boolean result = false;
    try {
        ModelPortType modelPort = getModelPort();
        UserType user = searchUserByName(modelPort, StringEscapeUtils.escapeXml(name));
        if (user == null) {
            // user with given screenname not found
            LOG.error("User with given screenname '" + name + "' not found in midpoint - giving up!");
        } else {
            LOG.info("Setting new name for user with oid '" + user.getOid() + "'");
            changeUserName(modelPort, user.getOid(), newFirstName, newLastName, newFullName);
            LOG.info("New user name set successfully for user with oid '" + user.getOid() + "'");
            result = true;
        }
    } catch (Exception e) {
        LOG.error("Error while changing user name in midpoint: " + e.getMessage(), e);
    }
    return result;
}

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

/**
 * ?, ?DeclaredMethod,?./* w  w  w.ja v a 2s .  c  om*/
 * ?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.notNull(methodName, "method can't be null");
    Validate.notEmpty(methodName);

    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:com.edmunds.zookeeper.election.ZooKeeperElection.java

/**
 * Creates a new ZooKeeperElection with the given connection and root path.
 *
 * @param connection a ZooKeeper connection
 * @param rootPath   the root path for election member nodes
 */// w  w  w . j  a v a  2 s.  co m
public ZooKeeperElection(ZooKeeperConnection connection, String rootPath) {
    Validate.notNull(connection);
    Validate.notEmpty(rootPath);
    if (!rootPath.startsWith("/") || rootPath.endsWith("/")) {
        String message = String.format("Invalid election root path: %s", rootPath);
        logger.error(message);
        throw new RuntimeException(message);
    }

    this.connection = connection;
    this.electionNodes = new ConcurrentHashMap<String, Boolean>();
    this.rootPath = rootPath;
    this.listeners = new HashSet<ZooKeeperElectionListener>();
}

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

/**
 *
 * @param urlStr//from  w w w .j a  va  2 s.c om
 *            cannot be null or empty
 * @return true if one end-point location of the SSO / SLO services matches
 *         the specified URL. otherwise false.
 */
public boolean isMatchingUrl(String urlStr) {
    Validate.notEmpty(urlStr);
    for (ServiceEndpoint sso : ssoServices) {
        if (sso.getEndpoint().equals(urlStr)) {
            return true;
        }
    }
    for (ServiceEndpoint slo : sloServices) {
        if (slo.getEndpoint().equals(urlStr)) {
            return true;
        }
    }
    return false;
}

From source file:ar.com.zauber.commons.gis.street.impl.SQLStreetsDAO.java

/** @see StreetsDAO#geocode(String, int) */
public final Collection<GeocodeResult> geocode_(final String streetParam, final int altura, final Integer id) {
    Validate.notEmpty(streetParam);

    String streetFiltered = executeFilters(streetParam);

    final Collection<Object> args = new ArrayList<Object>();
    args.add(streetFiltered);//from   ww  w.  j  a  v  a2 s . c o  m
    args.add(altura);
    if (id != null) {
        args.add(id.intValue());
    }

    final Collection<GeocodeResult> ret = new ArrayList<GeocodeResult>();
    final String q = "select * from geocode_ba(?, ?)" + (id == null ? "" : " where id=?");
    template.query(q, args.toArray(), new ResultSetExtractor() {
        public final Object extractData(final ResultSet rs) throws SQLException, DataAccessException {

            while (rs.next()) {
                try {
                    ret.add(new GeocodeResult(rs.getInt("id"), rs.getString("nomoficial"), rs.getInt("altura"),
                            "AR", (Point) wktReader.read(rs.getString("astext"))));
                } catch (ParseException e) {
                    throw new DataRetrievalFailureException("parsing feature geom");
                }
            }

            return null;
        }
    });

    return ret;
}