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:com.nebhale.cyclinglibrary.web.PointController.java

@Autowired
PointController(@Value("#{systemEnvironment.GOOGLE_API_KEY}") String apiKey,
        CollectionRepository collectionRepository, ItemRepository itemRepository,
        PolylineEncoder polylineEncoder) {
    Assert.hasText(apiKey, "The enviroment variable 'GOOGLE_API_KEY' must be specified");

    this.apiKey = apiKey;
    this.collectionRepository = collectionRepository;
    this.itemRepository = itemRepository;
    this.polylineEncoder = polylineEncoder;
}

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

/**
 * @see GroupManager#addUserToGroup(String, String)
 */// w  w w. j a  v  a 2 s  .  c o  m
@Transactional
public void addUserToGroup(String username, String groupname) {
    Assert.hasText(username, "username must not be empty");
    Assert.hasText(groupname, GROUPNAME_EMPTY_ERROR);

    final SecurityGroup group = userDetailsServiceHelper.loadGroupByGroupName(groupname);
    final SecurityUser user = (SecurityUser) userDetailsManager.loadUserByUsername(username);
    group.addUser(user);
}

From source file:com.github.gfernandez598.swf.conversation.optforrepl.SessionMapConversationContainer.java

/**
 * Create a new conversation container.//from w  w w. j  a va 2 s .  com
 * 
 * @param maxConversations
 *            the maximum number of allowed concurrent conversations, -1 for
 *            unlimited
 * @param lockTimeout
 *            lock acquisition timeout of conversation in seconds
 * @param sessionKey
 *            the key of this conversation container in the session
 */
public SessionMapConversationContainer(int maxConversations, int lockTimeout, String sessionKey) {
    Assert.hasText(sessionKey, "A sessionKey must be supplied.");
    this.maxConversations = maxConversations;
    this.lockTimeoutSeconds = lockTimeout;
    this.sessionKey = sessionKey;
    this.conversations = new ConcurrentLinkedQueue<ConversationId>();
}

From source file:org.esco.portlet.changeetab.dao.impl.LdapUserDao.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(this.ldapTemplate, "No LdapTemplate configured !");
    Assert.hasText(this.userDn, "No user dn configured !");
    Assert.hasText(this.userIdTemplate, "No user Id template configured !");
    Assert.hasText(this.currentEtabIdLdapKey, "No current etab Id Ldap key configured !");

    Assert.state(this.userDn.contains(this.userIdTemplate), "User dn doesn't contain the user Id template !");
}

From source file:com.excilys.ebi.spring.dbunit.test.MyEntityDao.java

@Override
public void deleteById(final String id) {
    Assert.hasText(id, "id required");
    getHibernateTemplate().execute(new HibernateCallback<Integer>() {
        @Override//from w  w w .j  ava  2 s. com
        public Integer doInHibernate(Session session) throws HibernateException {
            return session.createQuery("delete from " + MyEntity.class.getName() + " where id=:id")
                    .setString("id", id).executeUpdate();
        }
    });
}

From source file:org.cleverbus.core.common.route.SpringWsUriBuilder.java

@Override
public String getInWsUri(QName qName, String endpointMappingRef, @Nullable String params) {
    Assert.notNull(qName, "the qName must not be null");
    Assert.hasText(endpointMappingRef, "the endpointMappingRef must not be empty");

    return "spring-ws:rootqname:" + qName + "?endpointMapping=#" + endpointMappingRef
            + (params != null ? "&" + params : "");
}

From source file:com.frank.search.solr.core.query.GroupOptions.java

/**
 * Adds a group request for a {@link Field} using its name.
 * //from   w w w  . j  av a  2 s.  c om
 * @param fieldName
 * @return
 */
public GroupOptions addGroupByField(String fieldName) {

    Assert.hasText(fieldName, "Field.name for grouping must not be null/empty.");
    groupByFields.add(new SimpleField(fieldName));
    return this;
}

From source file:org.cleverbus.component.asynchchild.AsynchChildComponent.java

@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters)
        throws Exception {
    AsynchChildEndpoint endpoint = new AsynchChildEndpoint(uri, this);

    // parse URI - "service:operation"
    String endpointURI = ObjectHelper.after(uri, ":");
    if (endpointURI != null && endpointURI.startsWith("//")) {
        endpointURI = endpointURI.substring(2);
    }//from w ww. j a  v  a 2 s . co  m
    Assert.hasText(endpointURI, "Asynch-child endpoint URI must not be empty");

    // endpointURI = "service:operation"
    String serviceName = ObjectHelper.before(endpointURI, ":");
    String operationName = ObjectHelper.after(endpointURI, ":");

    if (operationName != null && operationName.contains("?")) {
        operationName = ObjectHelper.before(operationName, "?");
    }

    Assert.hasText(serviceName, "Service name can't be empty for asynch-child component");
    Assert.hasText(operationName, "Operation name can't be empty for asynch-child component");

    endpoint.setService(serviceName);
    endpoint.setOperationName(operationName);

    setProperties(endpoint, parameters);

    return endpoint;
}

From source file:org.insightedge.TestCluster.java

public void init() {
    Assert.notNull(schema, "'schema' property must be set");
    Assert.notNull(numberOfInstances, "'numberOfInstances' property must be set");
    Assert.notNull(numberOfBackups, "'numberOfBackups' property must be set");
    Assert.hasText(configPath, "'configPath' property must be set");

    LOG.info("Starting the cluster: config = {}", configPath);
    long time = System.currentTimeMillis();

    ClusterInfo clusterInfo = new ClusterInfo();
    clusterInfo.setSchema(schema);/*www .  jav a2  s .c  o  m*/
    clusterInfo.setNumberOfInstances(numberOfInstances);
    clusterInfo.setNumberOfBackups(numberOfBackups);

    IntegratedProcessingUnitContainerProvider provider = new IntegratedProcessingUnitContainerProvider();
    try {
        provider.addConfigLocation(configPath);
    } catch (IOException exception) {
        throw new IllegalArgumentException("Failed to read cluster member config from path: " + configPath,
                exception);
    }
    provider.setClusterInfo(clusterInfo);
    ProcessingUnitContainer container = provider.createContainer();

    checkContext(container);

    time = System.currentTimeMillis() - time;
    LOG.info("Cluster initialization finished in {} seconds", oneDigit(time / 1000.0));
}

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

/**
 * Create a new {@link UserPassword}.//  w  w w.  j a v a2s . c o  m
 *
 * @param user The {@link User} to assign
 * @param password The {@code password} as String to assign
 * @throws IllegalArgumentException when {@link User} or {@code password} is {@literal null} or empty
 */
public UserPassword(User user, String password) {
    Assert.notNull(user, "User must not be null");
    Assert.hasText(password, "Password must not be null");
    this.user = user;
    this.password = password;
}