Example usage for org.springframework.util StringUtils hasText

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

Introduction

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

Prototype

public static boolean hasText(@Nullable String str) 

Source Link

Document

Check whether the given String contains actual text.

Usage

From source file:org.opencredo.cloud.storage.test.TestPropertiesAccessor.java

protected static void checkPropertySet(String propertyName, String valueRetreived) {
    if (!StringUtils.hasText(valueRetreived) || valueRetreived.equals("${" + propertyName + "}")) {
        throw new RuntimeException("No value for key " + propertyName
                + " found you may want to add this to your maven settings.xml");
    }//from ww w.  j av  a  2s .  c om
}

From source file:nl.surfnet.coin.teams.service.impl.InvitationFormValidator.java

/**
 * {@inheritDoc}/*from   w w w.j  av a 2  s .  co m*/
 * <p/>
 * Fails if both the input field for manual email address input is empty and there is no
 * csv file with content
 */
@Override
public void validate(Object target, Errors errors) {
    InvitationForm form = (InvitationForm) target;

    if (StringUtils.hasText(form.getEmails())) {
        String[] emails = form.getEmails().split(",");
        for (String email : emails) {
            if (!EMAIL_VALIDATOR.isValid(email.trim(), null)) {
                errors.rejectValue("emails", "error.wrongFormattedEmailList");
                break;
            }

        }
    }

    if (form.hasCsvFile() && form.getCsvFile().getSize() == 0) {
        errors.rejectValue("csvFile", "invite.errors.EmptyCSV");
    }

    if (!(StringUtils.hasText(form.getEmails())) && (!form.hasCsvFile())) {
        errors.rejectValue("emails", "invite.errors.NoEmailAddresses");
    }

}

From source file:org.jasig.cas.adaptors.cas.LegacyTrustHandlerAdaptorAuthenticationHandler.java

public boolean authenticate(final Credentials credentials) {
    final LegacyCasTrustedCredentials casCredentials = (LegacyCasTrustedCredentials) credentials;

    return StringUtils.hasText(this.trustHandler.getUsername(casCredentials.getServletRequest()));
}

From source file:springfox.documentation.swagger.readers.operation.OperationNicknameIntoUniqueIdReader.java

@Override
public void apply(OperationContext context) {

    HandlerMethod handlerMethod = context.getHandlerMethod();
    ApiOperation methodAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);
    if (null != methodAnnotation && StringUtils.hasText(methodAnnotation.nickname())) {
        // Populate the value of nickname annotation into uniqueId
        context.operationBuilder().uniqueId(methodAnnotation.nickname());
        context.operationBuilder().codegenMethodNameStem(methodAnnotation.nickname());
    }// ww w  .  j av  a2  s . c om
}

From source file:org.sarons.spring4me.web.page.config.PageConfig.java

public String getId() {
    if (!StringUtils.hasText(id)) {
        this.id = UUID.randomUUID().toString();
    }
    return id;
}

From source file:web.logging.ExceptionLoggerAdvice.java

private String extractUrlFromRequest(HttpServletRequest request) {
    String url = request.getRequestURI();
    String query = request.getQueryString();
    if (StringUtils.hasText(query)) {
        url += "?" + request.getQueryString();
    }/*from  www  .j  a  va2 s.com*/
    return url;
}

From source file:org.openmrs.module.personalhr.web.taglib.GlobalPropertyTag.java

@Override
public int doStartTag() {
    this.log.debug("Entering GlobalPropertyTag.doStartTag");
    try {//from   w w w. ja v  a2 s . co  m
        //Add temporary privilege
        //PersonalhrUtil.addTemporaryPrivileges();

        Object value;
        if (StringUtils.hasText(this.listSeparator)) {
            value = Collections.singletonList(this.defaultValue);
        } else {
            value = this.defaultValue;
        }

        // If user is logged in
        if (Context.isAuthenticated()) {
            if (StringUtils.hasText(this.listSeparator)) {
                final String stringVal = Context.getAdministrationService().getGlobalProperty(this.key,
                        this.defaultValue);
                if (stringVal.trim().length() == 0) {
                    value = Collections.emptyList();
                } else {
                    value = Arrays.asList(stringVal.split(this.listSeparator));
                }
            } else {
                value = Context.getAdministrationService().getGlobalProperty(this.key, this.defaultValue);
            }
        }

        try {
            if (this.var != null) {
                this.pageContext.setAttribute(this.var, value);
            } else {
                this.pageContext.getOut().write(value.toString());
            }

        } catch (final Exception e) {
            this.log.error("error getting global property", e);
        }
    } finally {
        //PersonalhrUtil.removeTemporaryPrivileges();
    }
    return SKIP_BODY;
}

From source file:com.bg.jtown.social.twitter.TweetAfterSignInInterceptor.java

public void preConnect(ConnectionFactory<Twitter> provider, MultiValueMap<String, String> parameters,
        WebRequest request) {//from  w  w w  . ja v a2  s  . c  o  m
    logger.debug("Twitter PreConnect");
    if (StringUtils.hasText(request.getParameter(POST_TWEET_PARAMETER))) {
        request.setAttribute(POST_TWEET_ATTRIBUTE, Boolean.TRUE, WebRequest.SCOPE_SESSION);
    }
}

From source file:com.reactivetechnologies.platform.analytics.dto.ArffJsonRequest.java

@Override
public String toString() {
    StringBuilder s = new StringBuilder("@RELATION ");
    s.append(StringUtils.hasText(getRelation()) ? getRelation() : "stream").append("\n\n");

    for (Attribute a : getAttributes()) {
        s.append("@ATTRIBUTE ").append(a.getName()).append(" ");
        if (StringUtils.hasText(a.getType())) {
            if (a.getType().equalsIgnoreCase("string") || a.getType().equalsIgnoreCase("numeric")) {
                s.append(a.getType()).append("\n");
            } else if (a.getType().equalsIgnoreCase("date")) {
                s.append(a.getType()).append("\"").append(a.getSelector()[0]).append("\"").append("\n");
            }/*from   w  ww  .j  a  v a  2  s .  c  o m*/
        } else {
            s.append("{").append(StringUtils.arrayToCommaDelimitedString(a.getSelector())).append("}")
                    .append("\n");
        }
    }

    s.append("\n@DATA\n");
    for (String d : getData()) {
        s.append(d).append("\n");
    }

    return s.toString();
}

From source file:nl.gridshore.nosapi.example.web.SearchController.java

@RequestMapping(method = RequestMethod.GET)
public String search(@RequestParam(value = "q", required = false) String queryString, ModelMap modelMap) {
    SearchResults searchResults = null;//from   ww  w.  ja v a 2 s  . co m
    if (StringUtils.hasText(queryString)) {
        searchResults = dataProvider.searchForDocuments(queryString, SearchSort.DATE);
    }

    modelMap.addAttribute("results", searchResults);
    return "search";
}