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:com.formkiq.core.webflow.FlowManager.java

/**
 * Finds the current {@link WebFlow} if one exists.
 * @param req {@link HttpServletRequest}
 * @return {@link WebFlow}//from ww w. j  a va  2 s.  c o m
 */
private static WebFlow getCurrentWebFlow(final HttpServletRequest req) {

    Pair<String, Integer> webflowkey = getExecutionSessionKey(req.getParameter(PARAMETER_EXECUTION));
    String sessionKey = webflowkey.getLeft();

    if (StringUtils.hasText(sessionKey)) {
        Object obj = req.getSession().getAttribute(sessionKey);
        if (obj instanceof WebFlow) {
            WebFlow wf = (WebFlow) obj;
            return wf;
        }
    }

    throw new FlowNotFoundException();
}

From source file:io.cloudslang.schema.ConfValue.java

private Object fromString(String value) {
    value = System.getProperty("cloudslang.worker." + name, value);
    if (StringUtils.hasText(value)) {
        try {/*www  . j  ava 2s.  co  m*/
            return clazz.getConstructor(String.class).newInstance(value);
        } catch (Exception ex) {
            throw new RuntimeException(
                    "Failed to parse worker configuration attribute [" + name + "] value: " + value, ex);
        }
    } else {
        return defaultValue;
    }
}

From source file:org.openmrs.web.controller.remotecommunication.PostHl7Controller.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Map<String, Object> model = new HashMap<String, Object>();
    Boolean success = false;//  ww  w. j  a  va  2s . c o m
    if (!Context.isAuthenticated()) {
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        if (StringUtils.hasText(username) && StringUtils.hasText(password)) {
            Context.authenticate(username, password);
        } else {
            model.put("error", "PostHl7.missingAuthentication");
        }
    }
    if (Context.isAuthenticated()) {
        String message = request.getParameter("hl7Message");
        String hl7Source = request.getParameter("source");
        if (StringUtils.hasText(message) && StringUtils.hasText(hl7Source)) {
            HL7Service service = Context.getHL7Service();
            HL7Source source = service.getHL7SourceByName(hl7Source);

            HL7InQueue hl7InQueue = new HL7InQueue();
            hl7InQueue.setHL7Data(message);
            hl7InQueue.setHL7Source(source);
            log.debug("source: " + hl7Source + " , message: " + message);
            Context.getHL7Service().saveHL7InQueue(hl7InQueue);
            success = true;
        } else {
            model.put("error", "PostHl7.sourceAndhl7MessageParametersRequired");
        }
    }
    model.put("success", success);
    return new ModelAndView(formView, "model", model);
}

From source file:com.gradecak.alfresco.mvc.Query.java

public Query exactAnd(Map<QName, Serializable> properties) {
    for (Entry<QName, Serializable> entry : properties.entrySet()) {
        Object value = entry.getValue();

        String convert = value == null ? null : convert(value);
        if (StringUtils.hasText(convert)) {
            this.and();
            this.property(entry.getKey()).exact(value);
        }//from  w  w  w  . ja va2s.co m
    }

    return this;
}

From source file:org.wallride.model.CategorySearchRequest.java

public boolean isEmpty() {
    if (StringUtils.hasText(getKeyword())) {
        return false;
    }//from   w w w  .  j a va  2s  .  c o m
    if (StringUtils.hasText(getLanguage())) {
        return false;
    }
    return true;
}

From source file:org.springdata.ehcache.config.CacheManagerFactoryBean.java

@Override
public void afterPropertiesSet() throws FileNotFoundException {

    Assert.hasText(configFile, "configFile property must be set");

    if (StringUtils.hasText(terracottaLicenseFile)) {
        System.getProperties().setProperty("com.tc.productkey.path", terracottaLicenseFile);
    }//from  w  w w.java2 s . c  om

    logger.info("Initializing ehcache ...");
    cacheManager = new CacheManager(configFile);

}

From source file:org.jasig.cas.adaptors.ldap.remote.RemoteAddressNonInteractiveCredentialsAction.java

protected Credentials constructCredentialsFromRequest(final RequestContext context) {
    final HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    final String remoteAddress = request.getRemoteAddr();

    if (StringUtils.hasText(remoteAddress)) {
        return new RemoteAddressCredentials(remoteAddress);
    }//  ww w.j a  v a 2  s. c o  m

    logger.debug("No remote address found.");
    return null;
}

From source file:com.uimirror.location.id.stepdef.LocationSerachByIdStepDef.java

@When("^I hit the url$")
public void i_hit_the_url() throws Throwable {
    String url = "http://localhost:8080/uim/location/";
    if (StringUtils.hasText(expanded))
        url += "?id=" + locationId + "&expanded=" + expanded;
    else//from w  w w.j a  va2 s  . c om
        url += "?id=" + locationId;
    ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, String.class);
    this.entity = entity;
}

From source file:nz.co.senanque.madura.spring.ConfigBeanDefinitionParser.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {
    bean.addPropertyReference("configuration", "configuration");
    String key = element.getAttribute("key");
    if (StringUtils.hasText(key)) {
        bean.addPropertyValue("key", key);
    }//from  www  .  j  ava 2 s . c  o  m
}

From source file:csns.web.validator.EditUserValidator.java

@Override
public void validate(Object target, Errors errors) {
    super.validate(target, errors);

    User user = (User) target;//from   w ww.  j  a v a 2 s.  co  m
    Long id = user.getId();

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "username", "error.field.required");

    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "primaryEmail", "error.field.required");

    String username = user.getUsername();
    if (StringUtils.hasText(username)) {
        User u = userDao.getUserByUsername(username);
        if (u != null && !u.getId().equals(id))
            errors.rejectValue("username", "error.user.username.taken");
    }

    String password1 = user.getPassword1();
    if (StringUtils.hasText(password1)) {
        if (password1.length() < 6)
            errors.rejectValue("password1", "error.user.password.short");
        if (!password1.equals(user.getPassword2()))
            errors.rejectValue("password2", "error.user.password.notmatch");
    }
}