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.sarons.spring4me.web.widget.config.WidgetConfig.java

public void setId(String id) {
    if (StringUtils.hasText(id)) {
        this.id = id;
    } else {/* ww w .j av a2s .  co m*/
        this.id = UUID.randomUUID().toString();
    }
}

From source file:com._4dconcept.springframework.data.marklogic.core.mapping.BasicMarklogicPersistentEntity.java

private BasicMarklogicPersistentEntity(TypeInformation<T> information,
        @Nullable Comparator<MarklogicPersistentProperty> comparator) {
    super(information, comparator);

    Class<T> rawType = getTypeInformation().getType();
    String fallback = MarklogicUrlUtils.getPreferredUrlPattern(rawType);

    Document document = this.findAnnotation(Document.class);

    if (document != null) {
        this.uri = StringUtils.hasText(document.uri()) ? document.uri() : fallback;
        this.defaultCollection = buildDefaultCollection(document);
        this.idInPropertyFragment = document.idInPropertyFragment();
    } else {//from w  ww.  j  a v a 2  s .  co m
        this.uri = fallback;
        this.defaultCollection = null;
        this.idInPropertyFragment = false;
    }
}

From source file:net.prasenjit.auth.service.ClientService.java

/**
 * <p>save.</p>//from   w  ww. j  ava 2  s  .  com
 *
 * @param client a {@link net.prasenjit.auth.domain.Client} object.
 * @return a {@link net.prasenjit.auth.domain.Client} object.
 */
@Transactional
public Client save(Client client) {
    if (!StringUtils.hasText(client.getClientId())) {
        client.setClientId(UUID.randomUUID().toString());
        client.setClientSecret(UUID.randomUUID().toString());
    }
    User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    client.setUser(user);

    return clientRepository.save(client);
}

From source file:nl.minbzk.dwr.zoeken.enricher.notifier.jms.endpoint.AttenderEndpoint.java

/**
 * Process the incoming message and delegate it according to its payload.
 * //from w  w  w.j av a2  s . c  o  m
 * @param message
 */
public void process(final Message<?> message) {
    final String action = message.getHeaders().get(HEADER_CHANNEL_ATTENDERACTION, String.class);

    if (StringUtils.hasText(action)) {
        if (action.equals(ATTENDER_ACTION_DELETE_DIRECT_RESULT))
            directResultCache.delete((String) message.getPayload());
        else if (action.equals(ATTENDER_ACTION_UPDATE_DIRECT_RESULT))
            directResultCache.update((NotifierProfile) message.getPayload());
        else
            logger.error("Unknown attender replication action '" + action + "' received. Discarding.");
    } else
        logger.error("Unknown attender replication action (no action header) received. Discarding.");
}

From source file:podd.search.impl.IndexSearcherImpl.java

@Override
public SearchResponse search(SearchCriteria criteria) {
    SolrQuery solrQuery = createQuery(criteria);

    // Only perform a search if there is a valid query
    if (StringUtils.hasText(solrQuery.getQuery())) {
        try {//from  w ww  .jav  a 2s .c  o m
            QueryResponse queryResponse = solrServer.query(solrQuery);

            return new SearchResponseImpl(queryResponse, criteria.getPageSize(),
                    solrQuery.getHighlightFragsize());
        } catch (SolrServerException e) {
            LOGGER.error("Found exception", e);
        }
    }

    return null;
}

From source file:biz.c24.io.spring.config.C24HttpMessageConverterBeanDefinitionParser.java

@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext context) {

    Object source = context.extractSource(element);

    String modelRef = element.getAttribute("model-ref");
    modelRef = StringUtils.hasText(modelRef) ? modelRef : C24ModelBeanDefinitionParser.DEFAULT_BEAN_NAME;

    Set<BeanDefinition> formats = new ManagedSet<BeanDefinition>();
    for (Element formatElement : DomUtils.getChildElementsByTagName(element, "format")) {
        formats.add(formatParser.parse(formatElement, context));
    }/*from  w  ww .j ava2 s.  co m*/

    // Create C24HttpMessageConverter bean
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(C24HttpMessageConverter.class);
    builder.addConstructorArgReference(modelRef);
    builder.addConstructorArgValue(formats);

    return getSourcedBeanDefinition(builder, source);
}

From source file:fr.univlorraine.mondossierweb.utils.PropertyUtils.java

/** Retourne le champ de l'index elasticSearch correspondant au code de l'objet */
public static String getElasticSearchChampCodeObjet() {
    String value = System.getProperty("context.param.elasticsearch.index.champcodeobjet");
    if (!StringUtils.hasText(value))
        throw new NullPointerException("param.elasticsearch.index.champcodeobjet cannot be null !");
    return value;
}

From source file:com.xpeppers.phonedirectory.utils.HttpRequestDatatableParameters.java

private int getParameterAsPrimitiveInt(String parameter) {
    String intParameter = request.getParameter(parameter);
    if (StringUtils.hasText(intParameter)) {
        return Integer.parseInt(intParameter);
    }//from w w  w. j  a  v a 2s  .c  o  m
    return 0;
}

From source file:org.web4thejob.web.util.ComboItemConverter.java

@Override
public Object coerceToUi(Object val, Component comp) {
    Combobox combobox = (Combobox) comp;
    boolean found = false;

    if (val == null) {
        combobox.setSelectedIndex(-1);//from   w w w. j a  va 2s  .  com
        return IGNORE;
    }

    if (combobox.getModel() != null) {
        throw new IllegalArgumentException("cannot work with a model");
    }

    for (Object item : combobox.getItems()) {
        if (val.equals(((Comboitem) item).getValue())) {
            combobox.setSelectedItem((Comboitem) item);
            found = true;
            break;
        }
    }

    if (!found) {
        Comboitem comboitem = new Comboitem();
        comboitem.setValue(val);
        comboitem.setLabel(val.toString());
        comboitem.setParent(combobox);
        combobox.setSelectedItem(comboitem);
    }

    if (StringUtils.hasText(combobox.getSelectedItem().getStyle())) {
        combobox.setStyle(combobox.getSelectedItem().getStyle());
    }

    return IGNORE;
}

From source file:com.izerui.user.UserSearchController.java

@RequestMapping("search")
public String search(@Valid UserSearchForm form, BindingResult result, @PageableDefaults Pageable pageable,
        Model model) {/*  www  .  j  a  v  a  2s.  c  o  m*/
    if (result.hasErrors()) {
        return "user/list";
    }

    String name = form.getName();
    String query = (StringUtils.hasText(name) ? name : "") + "%";
    Page<User> page = userService.findByNameLike(query, pageable);
    model.addAttribute("page", page);
    return "user/list";
}