Example usage for org.springframework.util Assert hasLength

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

Introduction

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

Prototype

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

Source Link

Document

Assert that the given String is not empty; that is, it must not be null and not the empty String.

Usage

From source file:us.swcraft.springframework.store.persistence.AerospikeTemplate.java

public void init() {
    Assert.hasLength(namespace, "Aerospike 'namespace' name is not configured");
    Assert.hasLength(setname, "Aerospike 'setname' name is not configured");

    deletePolicy = new WritePolicy();
    deletePolicy.commitLevel = CommitLevel.COMMIT_MASTER;
    deletePolicy.timeout = 2000;//from  www  .  j a  va2 s .c o m

    writePolicyUpdate = new WritePolicy();
    writePolicyUpdate.expiration = expiration;
    writePolicyUpdate.recordExistsAction = RecordExistsAction.UPDATE;
    writePolicyUpdate.commitLevel = CommitLevel.COMMIT_ALL;
    writePolicyUpdate.timeout = 2000;

    writePolicyCommitMaster = new WritePolicy();
    writePolicyCommitMaster.recordExistsAction = RecordExistsAction.UPDATE;
    writePolicyCommitMaster.commitLevel = CommitLevel.COMMIT_MASTER;
    writePolicyCommitMaster.timeout = 2000;

    writePolicyCreateOnly = new WritePolicy();
    writePolicyCreateOnly.expiration = expiration;
    writePolicyCreateOnly.recordExistsAction = RecordExistsAction.CREATE_ONLY;
    writePolicyCreateOnly.commitLevel = CommitLevel.COMMIT_ALL;
    writePolicyCreateOnly.timeout = 2000;

    readPolicy = new Policy();
    readPolicy.timeout = 2000;
}

From source file:us.swcraft.springframework.session.store.aerospike.AerospikeTemplate.java

public void init() {
    Assert.hasLength(namespace, "Aerospike 'namespace' name for session data is not configured");
    Assert.hasLength(setname, "Aerospike 'setname' name for session data is not configured");

    deletePolicy = new WritePolicy();
    deletePolicy.commitLevel = CommitLevel.COMMIT_MASTER;

    writePolicy = new WritePolicy();
    writePolicy.recordExistsAction = RecordExistsAction.UPDATE;
    writePolicy.commitLevel = CommitLevel.COMMIT_ALL;

    readPolicy = new Policy();
}

From source file:com.skymobi.monitor.security.MongoUserManager.java

public void registerUser(User user) throws RegisterException {
    Assert.hasLength(user.getUsername(), "username can't  be empty");
    Assert.hasLength(user.getPassword(), "password can't  be empty");
    if (loadUserByUsername(user.getUsername()) != null) {
        throw new RegisterException("err.username_has_exist");
    }/*from w ww .  jav  a  2s .  c  om*/
    logger.info("register a user = {} ", user);
    saveUser(user);

}

From source file:com.wavemaker.commons.io.ResourcePath.java

/**
 * Get a new path relative to this one./*from   www .  ja  v  a2 s . c o m*/
 * 
 * @param path the path to obtain.
 * @return a new path
 */
public ResourcePath get(String path) {
    Assert.hasLength(path, "Path must not be empty");
    ResourcePath rtn = this;
    if (path.startsWith("/")) {
        rtn = new ResourcePath();
        path = path.substring(1);
    }
    while (path.indexOf("/") != -1) {
        rtn = rtn.newPath(path.substring(0, path.indexOf("/")));
        path = path.substring(path.indexOf("/") + 1);
    }
    return rtn.newPath(path);
}

From source file:com.wavemaker.commons.io.store.StoredFolder.java

@Override
public Folder getFolder(String name) {
    Assert.hasLength(name, "Name must not be empty");
    JailedResourcePath folderPath = getPath().get(name);
    return getStore().getFolder(folderPath);
}

From source file:com.acc.conv.Oauth2AccessTokenConverter.java

@Override
public void marshal(final Object source, final HierarchicalStreamWriter writerOrig,
        final MarshallingContext context) {
    final OAuth2AccessToken token = (OAuth2AccessToken) source;
    final ExtendedHierarchicalStreamWriter writer = (ExtendedHierarchicalStreamWriter) writerOrig
            .underlyingWriter();/* w ww.  ja  va  2s  .  c  o  m*/

    writer.startNode(OAuth2AccessToken.ACCESS_TOKEN, String.class);
    writer.setValue(formattedValue(token.getValue()));
    writer.endNode();

    writer.startNode(OAuth2AccessToken.TOKEN_TYPE, String.class);
    writer.setValue(formattedValue(token.getTokenType()));
    writer.endNode();

    final OAuth2RefreshToken refreshToken = token.getRefreshToken();
    if (refreshToken != null) {
        writer.startNode(OAuth2AccessToken.REFRESH_TOKEN, String.class);
        writer.setValue(formattedValue(refreshToken.getValue()));
        writer.endNode();

    }
    final Date expiration = token.getExpiration();
    if (expiration != null) {
        final long now = System.currentTimeMillis();
        writer.startNode(OAuth2AccessToken.EXPIRES_IN, Integer.class);
        writer.setValue(String.valueOf((expiration.getTime() - now) / 1000));
        writer.endNode();
    }
    final Set<String> scope = token.getScope();
    if (scope != null && !scope.isEmpty()) {
        final StringBuffer scopes = new StringBuffer();
        for (final String s : scope) {
            Assert.hasLength(s, "Scopes cannot be null or empty. Got " + scope);
            scopes.append(s);
            scopes.append(' ');
        }

        writer.startNode(OAuth2AccessToken.SCOPE, String.class);
        writer.setValue(formattedValue(scopes.substring(0, scopes.length() - 1)));
        writer.endNode();
    }
    final Map<String, Object> additionalInformation = token.getAdditionalInformation();
    for (final String key : additionalInformation.keySet()) {
        writer.startNode(key, String.class);
        writer.setValue(formattedValue(String.valueOf(additionalInformation.get(key))));
        writer.endNode();
    }
}

From source file:grails.plugin.springsecurity.authentication.encoding.DigestAuthPasswordEncoder.java

public void afterPropertiesSet() {
    Assert.hasLength(realm, "realm is required");
}

From source file:grails.plugins.springsecurity.DigestAuthPasswordEncoder.java

/**
 * {@inheritDoc}/*  www. j a  va 2  s  . com*/
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 */
public void afterPropertiesSet() {
    Assert.hasLength(_realm, "realm is required");
}

From source file:fr.paris.lutece.plugins.mydashboard.service.MyDashboardComponent.java

/**
 * {@inheritDoc}/*www.  ja  v  a  2s  .  co m*/
 */
@Override
public void afterPropertiesSet() throws Exception {
    Assert.hasLength(getComponentId(), "Dashboard components must have a non null id");

    if (getComponentId().length() > MY_DASHBOARD_COMPONENT_ID_MAXIMUM_SIZE) {
        throw new IllegalArgumentException("Dashboard components id must not be longer than 50 characters ("
                + getComponentId() + " has " + getComponentId().length() + ")");
    }
}

From source file:io.jmnarloch.spring.cloud.zuul.store.CassandraZuulRouteStore.java

/**
 * Creates new instance of {@link CassandraZuulRouteStore}.
 *
 * @param cassandraOperations the cassandra template
 * @param keyspace            the optional keyspace
 * @param table               the table name
 * @throws IllegalArgumentException if {@code keyspace} is {@code null}
 *                                  or {@code table} is {@code null} or empty
 *///from   w  ww.jav  a2 s  .  co  m
public CassandraZuulRouteStore(CassandraOperations cassandraOperations, String keyspace, String table) {
    Assert.notNull(cassandraOperations, "Parameter 'cassandraOperations' can not be null.");
    Assert.hasLength(table, "Parameter 'table' can not be empty.");
    this.cassandraOperations = cassandraOperations;
    this.keyspace = keyspace;
    this.table = table;
}