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:ee.kovmen.xtee.consumer.CustomServiceTemplate.java

public Object sendAndReceive(String uriString, WebServiceMessageCallback requestCallback,
        WebServiceMessageExtractor responseExtractor) {
    Assert.notNull(responseExtractor, "'responseExtractor' must not be null");
    Assert.hasLength(uriString, "'uri' must not be empty");
    TransportContext previousTransportContext = TransportContextHolder.getTransportContext();
    WebServiceConnection connection = null;
    try {/*from   w w w . j  a  v a 2s  .  co  m*/
        connection = createConnection(URI.create(uriString));
        TransportContextHolder.setTransportContext(new DefaultTransportContext(connection));
        MessageContext messageContext = new DefaultMessageContext(getMessageFactory());

        return doSendAndReceive(messageContext, connection, requestCallback, responseExtractor);
    } catch (TransportException ex) {
        throw new WebServiceTransportException("Could not use transport: " + ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new WebServiceIOException("I/O error: " + ex.getMessage(), ex);
    } finally {
        TransportUtils.closeConnection(connection);
        TransportContextHolder.setTransportContext(previousTransportContext);
    }
}

From source file:com.jaspersoft.jasperserver.api.metadata.user.service.impl.RequestAuthenticationProcessingFilter.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(getDefaultTargetUrl(), "defaultTargetUrl must be specified");
    Assert.hasLength(getAuthenticationFailureUrl(), "authenticationFailureUrl must be specified");
    Assert.notNull(getAuthenticationManager(), "authenticationManager must be specified");
    Assert.notNull(getRememberMeServices());
}

From source file:com.jpoweredcart.common.mock.servlet.MockServletContext.java

public void declareRoles(String... roleNames) {
    Assert.notNull(roleNames, "Role names array must not be null");
    for (String roleName : roleNames) {
        Assert.hasLength(roleName, "Role name must not be empty");
        this.declaredRoles.add(roleName);
    }/*from  w  w w  .  j  a v a  2 s .  c  om*/
}

From source file:com.kingen.service.org.OrgService.java

@ServiceLogAnnotation(action = "")
public void delOrgUsers(String orgId, List<String> userIds, Boolean synToActiviti) {

    Assert.hasLength(orgId, "ID?");
    Assert.notEmpty(userIds, "ID?");
    dao.delOrgUsers(orgId, userIds);//  w  w  w .j av  a 2 s  .c o  m
    // ??Activiti Identify?
    if (synToActiviti) {

        for (String userId : userIds) {
            identityService.deleteMembership(userId, orgId);
        }

    }

}

From source file:com.kingen.service.org.OrgService.java

@ServiceLogAnnotation(action = "")
public void delOrg(String orgId, Boolean synToActiviti) {

    Assert.hasLength(orgId, "ID?");

    dao.delOrg(orgId);//from w  w w  .  j a  v  a  2 s.  co  m

    if (synToActiviti) {
        identityService.deleteGroup(orgId);
    }

}

From source file:com.newinit.email.MailServiceImpl.java

/**
 * envo de email con attachments//from w  w w . j  ava2s  .c  o  m
 *
 * @param to correo electrnico del destinatario
 * @param subject asunto del mensaje
 * @param text cuerpo del mensaje
 * @param attachments ficheros que se anexarn al mensaje
 */
@Override
public void send(String to, String subject, String text, File... attachments) {
    // chequeo de parmetros 
    Assert.hasLength(to, "email 'to' needed");
    Assert.hasLength(subject, "email 'subject' needed");
    Assert.hasLength(text, "email 'text' needed");

    // asegurando la trazabilidad
    if (log.isDebugEnabled()) {
        final boolean usingPassword = !"".equals(mailSender.getPassword());
        log.debug("Sending email to: '" + to + "' [through host: '" + mailSender.getHost() + ":"
                + mailSender.getPort() + "', username: '" + mailSender.getUsername() + "' usingPassword:"
                + usingPassword + "].");
        log.debug("isActive: " + active);
    }
    // el servicio esta activo?
    if (!active) {
        return;
    }

    // plantilla para el envo de email
    final MimeMessage message = mailSender.createMimeMessage();

    try {
        // el flag a true indica que va a ser multipart
        final MimeMessageHelper helper = new MimeMessageHelper(message, true);

        // settings de los parmetros del envo
        helper.setTo(to);
        helper.setSubject(subject);
        helper.setFrom(getFrom());
        helper.setText(text);

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

    } catch (MessagingException e) {
        new RuntimeException(e);
    }

    // el envo
    this.mailSender.send(message);
}

From source file:com.thoughtworks.go.http.mocks.MockServletContext.java

@Override
public void declareRoles(String... roleNames) {
    Assert.notNull(roleNames, "Role names array must not be null");
    for (String roleName : roleNames) {
        Assert.hasLength(roleName, "Role name must not be empty");
        this.declaredRoles.add(roleName);
    }/*from  ww  w.  ja  va2s  .  c  om*/
}

From source file:de.juwimm.cms.beans.foreign.security.ConQuestDaoAuthenticationProvider.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(loginContextName, "loginContextName must be set on " + getClass());
}

From source file:io.micrometer.spring.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.//  ww w  .j  av  a2  s. co m
 */
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.toMillis());
}

From source file:org.acegisecurity.captcha.CaptchaChannelProcessorTemplate.java

/**
 * Verify if entryPoint and keyword are ok
 *
 * @throws Exception if not//from w w w  .j a  v  a 2s . c om
 */
public void afterPropertiesSet() throws Exception {
    Assert.notNull(entryPoint, "entryPoint required");
    Assert.hasLength(keyword, "keyword required");
}