Example usage for org.springframework.util StringUtils isEmpty

List of usage examples for org.springframework.util StringUtils isEmpty

Introduction

In this page you can find the example usage for org.springframework.util StringUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable Object str) 

Source Link

Document

Check whether the given object (possibly a String ) is empty.

Usage

From source file:io.fabric8.spring.cloud.kubernetes.config.SecretsPropertySource.java

private static String getApplicationName(Environment env, SecretsConfigProperties config) {
    String name = config.getName();
    if (StringUtils.isEmpty(name)) {
        LOGGER.debug("Secret name has not been set, taking it from property/env {} (default={})",
                Constants.SPRING_APPLICATION_NAME, Constants.FALLBACK_APPLICATION_NAME);

        name = env.getProperty(Constants.SPRING_APPLICATION_NAME, Constants.FALLBACK_APPLICATION_NAME);
    }// ww w .  j  a  va2s.  c  o m

    return name;
}

From source file:asia.gkc.vneedu.authorization.resolver.ActiveUserArgumentResolver.java

@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
        NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

    String uuid = (String) webRequest.getAttribute(Constants.USER_ID_IN_REQUEST,
            RequestAttributes.SCOPE_REQUEST);

    logger.info("Inject User[" + uuid + "] into parameter.");

    if (!StringUtils.isEmpty(uuid)) {
        return userService.getObjectById(uuid);
    }/* w  w w.  j a  v  a2  s .com*/

    return null;
    //throw new MissingServletRequestPartException(Constants.USER_ID_IN_REQUEST);
}

From source file:com.jive.myco.seyren.api.bean.ChartsBean.java

@Override
public Response getCustomChart(String target, int width, int height, String from, String to,
        String warnThreshold, String errorThreshold, boolean hideLegend, boolean hideAxes) {

    BigDecimal warn;/* w  ww  .  j av a  2 s  .  c om*/
    if (StringUtils.isEmpty(warnThreshold)) {
        warn = null;
    } else {
        warn = new BigDecimal(warnThreshold);
    }

    BigDecimal error;
    if (StringUtils.isEmpty(errorThreshold)) {
        error = null;
    } else {
        error = new BigDecimal(errorThreshold);
    }

    return getChart(target, width, height, from, to, warn, error, hideLegend, hideAxes);

}

From source file:uk.gov.nationalarchives.discovery.taxonomy.common.repository.lucene.TrainingSetRepository.java

/**
 * Create a lucene document from an trainingDocument object and add it to
 * the TrainingIndex index//from w  ww. java  2  s .  com
 * 
 * @param trainingDocument
 * @throws IOException
 */
public void indexTrainingSetDocument(TrainingDocument trainingDocument, IndexWriter writer) throws IOException {
    // TODO TSETBASED bulk index, this is far too slow to do it unitary!

    try {
        if (!StringUtils.isEmpty(trainingDocument.getDescription())) {
            trainingDocument
                    .setDescription(LuceneHelperTools.removePunctuation(trainingDocument.getDescription()));
        }
        if (!StringUtils.isEmpty(trainingDocument.getContextDescription())) {
            trainingDocument.setContextDescription(
                    LuceneHelperTools.removePunctuation(trainingDocument.getContextDescription()));
        }
        if (!StringUtils.isEmpty(trainingDocument.getTitle())) {
            trainingDocument.setTitle(LuceneHelperTools.removePunctuation(trainingDocument.getTitle()));
        }
        Document doc = LuceneTaxonomyMapper.getLuceneDocumentFromTrainingDocument(trainingDocument);
        writer.addDocument(doc);
    } catch (Exception e) {
        logger.error(".indexTrainingSetDocument: an error occured on document: '{}', message: {}",
                trainingDocument.getDocReference(), e.getMessage());
    }
}

From source file:de.dlopes.stocks.facilitator.services.impl.FinanzenNetIndexHTMLExtractorImpl.java

@Override
public List<String> getFinanceData(String url, FinanceDataType dataType) {

    List<String> list = new ArrayList<String>();

    try {// ww  w.  j a v a  2 s .c om

        Document doc = null;
        if (url.startsWith("file://")) {
            File input = new File(url.replaceFirst("file://", ""));
            doc = Jsoup.parse(input, "UTF-8");
        } else {
            URL input = new URL(url);
            doc = Jsoup.parse(input, 30000);
        }

        //String index = doc.body().select("div#mainWrapper > div.main h1 > a").text();
        Elements elements = doc.body().select("#fragIndexBarView > table tr");

        for (Element e : elements) {
            String text = e.select("td > div").text();

            // Guard: move on when the text is empty
            if (StringUtils.isEmpty(text)) {
                continue;
            }

            text = StringUtils.trimAllWhitespace(text);
            list.add(text);

        }

    } catch (IOException e) {
        e.printStackTrace();
    }

    return list;
}

From source file:com.seyren.api.bean.ChartsBean.java

@Override
public Response getCustomChart(String target, String graphiteBaseUrl, int width, int height, String from,
        String to, String warnThreshold, String errorThreshold, boolean hideLegend, boolean hideAxes) {

    BigDecimal warn;//from   w w w .  j av  a2s.  c o m
    if (StringUtils.isEmpty(warnThreshold)) {
        warn = null;
    } else {
        warn = new BigDecimal(warnThreshold);
    }

    BigDecimal error;
    if (StringUtils.isEmpty(errorThreshold)) {
        error = null;
    } else {
        error = new BigDecimal(errorThreshold);
    }

    return getChart(graphiteBaseUrl, target, width, height, from, to, warn, error, hideLegend, hideAxes);

}

From source file:org.psikeds.resolutionengine.rules.EventStack.java

public Event removeEvent(final String eid) {
    return (StringUtils.isEmpty(eid) ? null : this.remove(eid));
}

From source file:com.formkiq.core.service.SpringSecurityService.java

/**
 * Check Request for Basic Authorization.
 * @param authorization {@link String}// w w  w . j  a v  a2s  .com
 * @return clientid {@link String}
 */
public String checkBasicAuthorization(final String authorization) {

    String value = authorization;

    if (!StringUtils.isEmpty(value)) {

        value = value.replaceAll("Basic ", "");
        String[] args = Strings.decode(value, ":");
        String clientid = args[0];
        String clientSecret = args[1];

        if (this.oauthservice.isValidClient(clientid, clientSecret)) {
            return clientid;
        }
    }

    throw new BadCredentialsException("User does not have access to Client");
}

From source file:com.ocs.dynamo.importer.impl.BaseTextImporter.java

/**
 * Reads a numeric value from a unit (and falls back to a default if needed)
 * //  ww w.jav a 2  s.  co m
 * @param unit
 *            the unit (cell or string value) to read from
 * @param field
 *            the field definition (contains a default value)
 */
@Override
protected Double getNumericValueWithDefault(String unit, XlsField field) {
    Double value = getNumericValue(unit);
    if (value == null && !StringUtils.isEmpty(field.defaultValue())) {
        value = Double.valueOf(field.defaultValue());
    }
    return value;
}

From source file:be.roots.taconic.pricingguide.service.MailServiceImpl.java

@Override
public void sendMail(Contact contact, byte[] pricingGuide) throws MessagingException {

    final MimeMessageHelper helper = new MimeMessageHelper(javaMailSender.createMimeMessage(), true);

    helper.setFrom(fromEmail);//from w  w  w  . j av a2s  .  c  o m

    if (StringUtils.isEmpty(testEmail)) {
        helper.setTo(contact.getEmail());
    } else {
        helper.setTo(testEmail.split(","));
    }

    if (!StringUtils.isEmpty(bccEmail)) {
        helper.setBcc(bccEmail.split(","));
    }

    helper.setSubject("Your " + documentTitle);

    final String body = "Dear " + contact.getFullName() + ",<br>" + "<br>" + "Your " + documentTitle
            + " is attached.<br>" + "<br>"
            + "Please <a href=\"http:www.taconic.com/customer-service/contact-us\">contact us</a> for any additional information.<br>"
            + "<br>" + "Taconic Biosciences, Inc.<br>" + "One Hudson City Centre<br>"
            + "Hudson, New York 12534<br>" + "North America +1 888 822-6642<br>" + "Europe +45 70 23 04 05<br>"
            + "info@taconic.com<br>" + "www.taconic.com";

    helper.setText(body, true);

    helper.addAttachment(documentFileName, new ByteArrayResource(pricingGuide));

    javaMailSender.send(helper.getMimeMessage());

}