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:org.pentaho.platform.engine.security.userroledao.hibernate.HibernateUserRoleDao.java

/**
 * Manually update role's users.//from   w  ww  . j a  va 2 s.  c o  m
 */
protected void removeUser(IPentahoRole roleToUpdate, String username)
        throws NotFoundException, UncategorizedUserRoleDaoException {
    Assert.notNull(roleToUpdate, Messages.getString("HibernateUserRoleDao.ERROR_0005_ROLE_CANNOT_BE_NULL")); //$NON-NLS-1$
    Assert.hasLength(roleToUpdate.getName(),
            Messages.getString("HibernateUserRoleDao.ERROR_0006_ROLE_NAME_CANNOT_BE_BLANK")); //$NON-NLS-1$
    Assert.hasLength(username, Messages.getString("HibernateUserRoleDao.ERROR_0002_USERNAME_CANNOT_BE_BLANK")); //$NON-NLS-1$

    IPentahoUser user = getUser(username);
    if (user != null) {
        user.removeRole(roleToUpdate);
        updateUser(user);
    } else {
        throw new NotFoundException(username);
    }
}

From source file:org.pentaho.platform.engine.security.userroledao.hibernate.HibernateUserRoleDao.java

public void setAllUsersQuery(String allUsersQuery) {
    Assert.hasLength(allUsersQuery,
            Messages.getString("HibernateUserRoleDao.ERROR_0007_ALL_USERS_QUERY_CANNOT_BE_BLANK")); //$NON-NLS-1$
    this.allUsersQuery = allUsersQuery;
}

From source file:org.pentaho.platform.engine.security.userroledao.hibernate.HibernateUserRoleDao.java

public void setAllRolesQuery(String allRolesQuery) {
    Assert.hasLength(allUsersQuery,
            Messages.getString("HibernateUserRoleDao.ERROR_0008_ALL_ROLES_QUERY_CANNOT_BE_BLANK")); //$NON-NLS-1$
    this.allRolesQuery = allRolesQuery;
}

From source file:org.pentaho.platform.web.http.security.HttpSessionReuseDetectionFilter.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(filterProcessesUrl, Messages.getInstance()
            .getString("HttpSessionReuseDetectionFilter.ERROR_0001_FILTERPROCESSESURL_NOT_SPECIFIED")); //$NON-NLS-1$
    Assert.hasLength(sessionReuseDetectedUrl, Messages.getInstance()
            .getString("HttpSessionReuseDetectionFilter.ERROR_0002_SESSIONREUSEDETECTEDURL_NOT_SPECIFIED")); //$NON-NLS-1$
}

From source file:org.rill.bpm.common.mail.support.TemplateMailSenderSupport.java

/**
 * @param encode the encode to set//  www.  ja  v  a2 s .  c  om
 */
public void setEncode(String encode) {
    this.encode = encode;
    Assert.hasLength(this.encode, "Encode is mismatch");
}

From source file:org.springframework.batch.core.step.tasklet.SystemCommandTasklet.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.hasLength(command, "'command' property value is required");
    Assert.notNull(systemProcessExitCodeMapper, "SystemProcessExitCodeMapper must be set");
    Assert.isTrue(timeout > 0, "timeout value must be greater than zero");
    Assert.notNull(taskExecutor, "taskExecutor is required");
    stoppable = jobExplorer != null;/*from   w w  w .jav  a2  s .com*/
}

From source file:org.springframework.boot.actuate.autoconfigure.ShellProperties.java

public void setAuth(String auth) {
    Assert.hasLength(auth, "Auth must not be empty");
    this.auth = auth;
    this.defaultAuth = false;
}

From source file:org.springframework.boot.actuate.metrics.export.prometheus.PrometheusPushGatewayManager.java

/**
 * Create a new {@link PrometheusPushGatewayManager} instance.
 * @param pushGateway the source push gateway
 * @param registry the collector registry to push
 * @param scheduler the scheduler used for operations
 * @param pushRate the rate at which push operations occur
 * @param job the job ID for the operation
 * @param groupingKey an optional set of grouping keys for the operation
 * @param shutdownOperation the shutdown operation that should be performed when
 * context is closed.//from  ww w. j av a  2s  . c  om
 */
public PrometheusPushGatewayManager(PushGateway pushGateway, CollectorRegistry registry,
        TaskScheduler scheduler, Duration pushRate, String job, Map<String, String> groupingKey,
        ShutdownOperation shutdownOperation) {
    Assert.notNull(pushGateway, "PushGateway must not be null");
    Assert.notNull(registry, "Registry must not be null");
    Assert.notNull(scheduler, "Scheduler must not be null");
    Assert.notNull(pushRate, "PushRate must not be null");
    Assert.hasLength(job, "Job must not be empty");
    this.pushGateway = pushGateway;
    this.registry = registry;
    this.job = job;
    this.groupingKey = groupingKey;
    this.shutdownOperation = (shutdownOperation != null) ? shutdownOperation : ShutdownOperation.NONE;
    this.scheduler = scheduler;
    this.scheduled = this.scheduler.scheduleAtFixedRate(this::push, pushRate);
}

From source file:org.springframework.boot.context.config.ConfigFileApplicationListener.java

/**
 * Set the search locations that will be considered as a comma-separated list. Each
 * search location should be a directory path (ending in "/") and it will be prefixed
 * by the file names constructed from {@link #setSearchNames(String) search names} and
 * profiles (if any) plus file extensions supported by the properties loaders.
 * Locations are considered in the order specified, with later items taking precedence
 * (like a map merge)./* w  w w.ja va 2  s .  c o m*/
 * @param locations the search locations
 */
public void setSearchLocations(String locations) {
    Assert.hasLength(locations, "Locations must not be empty");
    this.searchLocations = locations;
}

From source file:org.springframework.boot.context.config.ConfigFileApplicationListener.java

/**
 * Sets the names of the files that should be loaded (excluding file extension) as a
 * comma-separated list./*  w ww .  j  a v  a 2  s .  c  o  m*/
 * @param names the names to load
 */
public void setSearchNames(String names) {
    Assert.hasLength(names, "Names must not be empty");
    this.names = names;
}