Example usage for org.springframework.util Assert hasText

List of usage examples for org.springframework.util Assert hasText

Introduction

In this page you can find the example usage for org.springframework.util Assert hasText.

Prototype

public static void hasText(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Usage

From source file:io.galeb.core.entity.Farm.java

public Farm setApi(String api) {
    Assert.hasText(api,
            "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
    updateHash();//  w  w  w  . j  a  v  a  2  s. c o m
    this.api = api;
    return this;
}

From source file:com.azaptree.services.security.dao.SessionAttributeDAO.java

@Override
public String getAttributeJsonValue(final UUID sessionId, final String key) {
    Assert.notNull(sessionId, "sessionId is required");
    Assert.hasText(key, "key is required");
    try {//  w  ww.ja v  a 2  s. co  m
        return jdbc.queryForObject("select value from t_session_attribute where session_id = ? and name = ?",
                String.class, sessionId, key);
    } catch (final IncorrectResultSizeDataAccessException e) {
        return null;
    }
}

From source file:com.autentia.wuija.security.impl.hibernate.HibernateGroupManager.java

/**
 * @see GroupManager#createGroup(String, GrantedAuthority[])
 *///from   w  ww  .  j  a  v  a  2 s  .  c om
@Transactional
public void createGroup(String groupname, GrantedAuthority[] authorities) {
    Assert.hasText(groupname, GROUPNAME_EMPTY_ERROR);

    if (log.isDebugEnabled()) {
        log.debug("Creating group " + groupname + ", with roles: " + authorities);
    }
    final SecurityGroup group = new HibernateSecurityGroup(groupname);

    for (GrantedAuthority authority : authorities) {
        group.addAuthority(authority);
    }

    dao.persist(group);
}

From source file:com.emc.ecs.sync.source.DbListFilesystemSource.java

@Override
public void configure(SyncSource source, Iterator<SyncFilter> filters, SyncTarget target) {
    Assert.hasText(filenameColumn, "The property 'filenameColumn' is required");
    Assert.hasText(selectQuery, "The property 'selectQuery' is required.");
    Assert.notNull(dataSource, "The property 'dataSource' is required.");
    setUseAbsolutePath(true);//  w  ww.  ja  v a2s  .  c  om
}

From source file:com.kuprowski.redis.security.core.session.RedisSessionRegistry.java

@Override
public void refreshLastRequest(String sessionId) {
    Assert.hasText(sessionId, "SessionId required as per interface contract");

    SessionInformation info = getSessionInformation(sessionId);

    if (info != null) {
        info.refreshLastRequest();// www.  j a  v  a2 s .  co m
        sessionIdsTemplate.opsForValue().set(buildSessionIdsKey(sessionId), info);
    }
}

From source file:ruiliu2.practice.elasticsearch.client.TransportClientFactoryBean.java

protected void buildClient() throws Exception {
    client = new PreBuiltTransportClient(settings());
    Assert.hasText(clusterNodes, "[Assertion failed] clusterNodes settings missing.");
    for (String clusterNode : split(clusterNodes, COMMA)) {
        String hostName = substringBeforeLast(clusterNode, COLON);
        String port = substringAfterLast(clusterNode, COLON);
        Assert.hasText(hostName, "[Assertion failed] missing host name in 'clusterNodes'");
        Assert.hasText(port, "[Assertion failed] missing port in 'clusterNodes'");
        logger.info("adding transport node : " + clusterNode);
        client.addTransportAddress(/*w ww.  ja v a2 s . c om*/
                new InetSocketTransportAddress(InetAddress.getByName(hostName), Integer.valueOf(port)));
    }
    client.connectedNodes();
}

From source file:org.openwms.core.uaa.SecurityObject.java

/**
 * Create a new {@code SecurityObject} with name and description.
 *
 * @param name The name of the {@code SecurityObject}
 * @param description The description text of the {@code SecurityObject}
 * @throws IllegalArgumentException if name is {@literal null} or an empty String
 *//*from   w w  w.j  a va2  s . co m*/
public SecurityObject(String name, String description) {
    Assert.hasText(name, "A name of a SecurityObject must not be null");
    this.name = name;
    this.description = description;
}

From source file:fr.mby.portal.coreimpl.configuration.PropertiesConfigurationManager.java

@Override
public PropertiesConfiguration getConfiguration(final String key) throws IllegalArgumentException {
    Assert.hasText(key, "No key provided !");

    final PropertiesConfiguration config = this.configurationByKey.get(key);
    if (config == null) {
        throw new IllegalArgumentException("No configuration element found for key: " + key + " !");
    }//w w w. ja va  2  s .com

    return config;
}

From source file:com.azaptree.services.spring.application.config.SpringApplicationServiceConfig.java

public SpringApplicationServiceConfig(final String xmlLocation)
        throws IOException, ClassNotFoundException, JAXBException {
    Assert.hasText(xmlLocation, "xmlResourcePath is required");
    final PathMatchingResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
    final Resource resource = resourceResolver.getResource(xmlLocation);

    try (InputStream xml = resource.getInputStream()) {
        init(xml);// w  w w  .j  av  a  2  s . c  o m
    }
}

From source file:com.autentia.wuija.security.impl.hibernate.UserDetailsHqlProvider.java

/**
 * El constructor por defecto usa la infraestructura de WUIJA. Las clases hijas slo tienen que implementar el mtodo
 * <code>getUserClassName</code> para indicar la entidad sobre la que se va a trabajar. Esta entidad debe ser hija de
 * {@link SecurityUser}.//  www  .  j  a va  2 s .  c  o m
 * <p>
 * Si se quiere trabajar con una clase que no extiende {@link SecurityUser} bastar con poner en la clase hija de esta
 * clase (hija de UserDetailsHqlProvider) un constructor por defecto que sobreescriba los valores de las consultas.
 * <b>Ojo !!!</b> porque aunque no extienda de {@link SecurityUser}, s deber implementar la interfaz
 * <code>UserDetails</code> de Spring.
 */
protected UserDetailsHqlProvider() {
    final String userClassName = getUserClassName();
    Assert.hasText(userClassName, "getUserClassName() cannot return null or empty string");

    USER_BY_NAME_HQL = "select distinct u from " + userClassName + " as u " + " left join u.userAuthorities "
            + " left join u.groups as g " + " left join g.authorities " + " where u.username = ?";

    USERS_BY_ROLE_HQL = "select distinct u from " + userClassName + " as u "
            + " left join u.userAuthorities as a " + " left join u.groups as g "
            + " left join g.authorities as ga " + " where a.role = ? or ga.role = ?";

    USERS_BY_ROLE_HQL_ORDERBY = " order by u.username";

    ALL_GROUPS_HQL = "select distinct g from " + HibernateSecurityGroup.class.getSimpleName() + " as g "
            + " left join g.authorities " + " left join g.users ";

    ALL_USERS_HQL = "select distinct u from " + userClassName + " as u " + " left join u.userAuthorities "
            + " left join u.groups as g " + " left join g.authorities ";

    GROUP_BY_NAME_HQL = "select distinct g from " + HibernateSecurityGroup.class.getSimpleName() + " as g "
            + " left join g.authorities " + " left join g.users " + " where g.groupname = ?";

    UPDATE_USER_PASSWORD_BY_NAME_NATIVE_SQL = "update " + HibernateSecurityUser.class.getSimpleName()
            + " u set u.password = ?, u.lastPasswordChangeDate = now() where u.username = ?";

    PASSWORD_HISTORY_BY_NAME_HQL = "select u.oldPasswords from " + userClassName + " u where u.username = ?";

    UPDATE_USER_PASSWORD_HISTORY_BY_NAME_NATIVE_SQL = "update " + userClassName
            + " u set u.oldPasswords = ? where u.id =  (select h.id from "
            + HibernateSecurityUser.class.getSimpleName() + " h where h.username = ?)";

    USER_COMPLETE_NAME_BY_NAME_HQL = "select u.realname from " + userClassName + " u where u.username = ?";

}