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:com.wavemaker.commons.io.store.StoredFolder.java

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

From source file:org.jdbcluster.domain.DomainCheckerImpl.java

/**
 * returns the corresponding domain id//w  w  w .j  ava 2 s.com
 * 
 * @param cluster Cluster object to use
 * @param propPath path to the master or slave property
 * @return String domain id
 */
public String getDomainId(ICluster cluster, String propPath) {

    Assert.notNull(cluster, "Cluster may not be null");
    Assert.hasLength(propPath, "propPath may not be null");

    if (logger.isDebugEnabled())
        logger.debug("getDomainId for cluster [" + cluster.getClass().getName() + "] and Property Path ["
                + propPath + "]");

    String domId;
    Field fSlave = JDBClusterUtil.getField(propPath, cluster);

    DomainDependancy dd = fSlave.getAnnotation(DomainDependancy.class);
    if (dd == null) {
        Domain d = fSlave.getAnnotation(Domain.class);
        if (d == null)
            throw new ConfigurationException(
                    "no annotation @DomainDependancy or @Domain found on: " + propPath);
        domId = d.domainId();
    } else
        domId = dd.domainId();

    if (logger.isDebugEnabled())
        logger.debug("returning domain id [" + domId + "]");

    return domId;
}

From source file:com.buzzinate.buzzads.sso.CasAuthenticationEntryPoint.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(this.loginUrl, "loginUrl must be specified");
    Assert.notNull(this.serviceProperties, "serviceProperties must be specified");
}

From source file:com.autentia.wuija.mail.MailService.java

/**
 * send an e-mail//www . jav  a2 s.c om
 * 
 * @param to recipient e-mail
 * @param subject the subject of the e-mail
 * @param text the body of the e-mail
 * @param attachments an array of it
 * @throws EmailException if the e-mail cannot be prepare or send.
 */
public void send(String to, String subject, String text, File... attachments) {
    Assert.hasLength(to, "email 'to' needed");
    Assert.hasLength(subject, "email 'subject' needed");
    Assert.hasLength(text, "email 'text' needed");

    if (log.isDebugEnabled()) {
        final boolean usingPassword = StringUtils.isNotBlank(mailSender.getPassword());
        log.debug("Sending email to: '" + to + "' [through host: '" + mailSender.getHost() + ":"
                + mailSender.getPort() + "', username: '" + mailSender.getUsername() + "' usingPassword:"
                + usingPassword + "].");
        log.debug("isActive: " + active);
    }
    if (!active) {
        return;
    }

    final MimeMessage message = mailSender.createMimeMessage();

    try {
        // use the true flag to indicate you need a multipart message
        final MimeMessageHelper helper = new MimeMessageHelper(message, true);
        helper.setTo(to);
        helper.setSubject(subject);
        helper.setFrom(getFrom());
        helper.setText(text);

        if (attachments != null) {
            for (int i = 0; i < attachments.length; i++) {
                // let's attach each file
                final FileSystemResource file = new FileSystemResource(attachments[i]);
                helper.addAttachment(attachments[i].getName(), file);
                if (log.isDebugEnabled()) {
                    log.debug("File '" + file + "' attached.");
                }
            }
        }

    } catch (MessagingException e) {
        final String msg = "Cannot prepare email message : " + subject + ", to: " + to;
        log.error(msg, e);
        throw new MailPreparationException(msg, e);
    }
    this.mailSender.send(message);
}

From source file:org.esupportail.portlet.filemanager.services.evaluators.PreferenceEvaluator.java

/**
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 *//*ww  w.  j a  v  a 2  s  .c om*/
public void afterPropertiesSet() throws Exception {
    Assert.hasLength(attribute, "The portlet Attribute to evaluate must be set !");
    Assert.hasLength(value, "The value to compare must be set !");
}

From source file:com.baidu.cc.ConfigCenterClient.java

/**
 * crate {@link ConfigLoader}//from   w  w  w . j a  v  a  2  s.c o m
 * @return {@link ConfigLoader} instance
 */
public ConfigLoader createConfigLoader() {
    ccServerUrl = Constants.getServerUrl(ccServerUrl);
    Assert.hasLength(ccServerUrl, "property 'ccServerUrl' is blank.");

    ExtConfigServerService configServerService = createConfigService(ccServerUrl, connectionTimeout,
            readTimeout);

    ConfigLoader configLoader = new ConfigLoader();
    configLoader.setCcEnvId(Constants.getEnvId(String.valueOf(ccEnvId)));
    configLoader.setCcVersion(Constants.getVersion(String.valueOf(ccVersion)));
    configLoader.setProjectName(Constants.getProjectName(projectName));
    configLoader.setEnvName(Constants.getEnvName(envName));
    configLoader.setCcUser(Constants.getUser(ccUser));
    configLoader.setCcPassword(Constants.getPassword(ccPassword));
    configLoader.setCallbackInteval(callbackInteval);
    configLoader.setCcVersionName(Constants.getVersionName(ccVersionName));

    configLoader.setConfigServerService(configServerService);

    configLoader.init();

    return configLoader;
}

From source file:org.jasig.cas.authentication.RootCasException.java

private void initException(final String code) {
    Assert.hasLength(code, "The exception code cannot be blank");
    this.code = code;
}

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

@SuppressWarnings("unchecked")
@Override/*from   w ww. j  a v a2 s .c o  m*/
public <T extends Resource> T get(String name, Class<T> resourceType) {
    Assert.hasLength(name, "Name must not be empty");
    Assert.notNull(resourceType, "ResourceType must not be null");
    if (resourceType.equals(Folder.class)) {
        return (T) getFolder(name);
    }
    if (resourceType.equals(File.class)) {
        return (T) getFile(name);
    }
    return (T) getExisting(name);
}

From source file:org.kmnet.com.fw.common.codelist.JdbcCodeList.java

/**
 * This method is called after the codelist is initialized Checks whether the values of querySql, valueColumn, labelColumn
 * and namedJdbcTemplate properties are set
 * @see org.kmnet.com.fw.common.codelist.AbstractReloadableCodeList#afterPropertiesSet()
 *///from w w  w.ja  v a 2 s  .c  o m
@Override
public void afterPropertiesSet() {
    Assert.hasLength(querySql, "querySql is empty");
    Assert.hasLength(valueColumn, "valueColumn is empty");
    Assert.hasLength(labelColumn, "labelColumn is empty");
    Assert.notNull(jdbcTemplate, "namedJdbcTemplate (or dataSource) is empty");
    super.afterPropertiesSet();
}

From source file:com.baidu.cc.patch.struts2.ReloadableParametersInterceptor.java

/**
 * do property load here.//from www  . jav a2 s. co  m
 */
@Override
public void init() {
    super.init();

    ccServerUrl = Constants.getServerUrl(ccServerUrl);
    ccUser = Constants.getUser(ccUser);
    ccPassword = Constants.getPassword(ccPassword);

    Assert.hasLength(ccServerUrl, "property 'ccServerUrl' can not blank");
    Assert.hasLength(ccUser, "property 'ccUser' can not blank");
    Assert.hasText(ccVersionName, "property 'ccVersionName' can not blank");

    configLoader = ConfigLoader.createConfigLoader(this);

}