Example usage for org.springframework.util StringUtils hasLength

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

Introduction

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

Prototype

public static boolean hasLength(@Nullable String str) 

Source Link

Document

Check that the given String is neither null nor of length 0.

Usage

From source file:org.terasoluna.gfw.functionaltest.app.pagination.PaginationController.java

@RequestMapping(value = { "20_1", "20_2", "20_3", "20_4", "20_5" }, method = RequestMethod.GET)
public String fuinctionTest_20_x(PersonSearchForm form, @PageableDefault(sort = "personId") Pageable pageable,
        Model model) {/*from  w  w w .  j av  a  2s  .com*/

    if (!StringUtils.hasLength(form.getName())) {
        return "pagination/search";
    }

    Page<Person> page = paginationService.findPersonByName(form.getName(), pageable);

    model.addAttribute("page", page);

    return "pagination/search";
}

From source file:org.terasoluna.gfw.functionaltest.app.pagination.PaginationController.java

@RequestMapping(value = { "21_1", "21_1/{page}/{size}", "21_2",
        "21_2/{page}/{size}" }, method = RequestMethod.GET)
public String fuinctionTest_21_x(PersonSearchForm form, @PageableDefault(sort = "personId") Pageable pageable,
        Model model) {/*  w  ww.  j a v a  2 s.  c o  m*/

    if (!StringUtils.hasLength(form.getName())) {
        return "pagination/searchPathTmplAndCriteriaQuery";
    }

    Page<Person> page = paginationService.findPersonByName(form.getName(), pageable);

    model.addAttribute("page", page);

    return "pagination/searchPathTmplAndCriteriaQuery";
}

From source file:org.terasoluna.gfw.functionaltest.app.pagination.PaginationController.java

@RequestMapping(value = { "22_1", "22_2" }, method = RequestMethod.GET)
public String fuinctionTest_22_x(PersonSearchForm form,
        @PageableDefault(sort = "personId", direction = Direction.DESC) Pageable pageable, Model model) {

    if (!StringUtils.hasLength(form.getName())) {
        return "pagination/searchQueryTmplAndCriteriaQuery";
    }//from w  w  w.  j av a  2 s.c om

    Page<Person> page = paginationService.findPersonByName(form.getName(), pageable);

    model.addAttribute("page", page);

    return "pagination/searchQueryTmplAndCriteriaQuery";
}

From source file:com.iana.dver.controller.DverAdminController.java

@RequestMapping(value = "/admin/users/filter", produces = "application/json", method = RequestMethod.GET)
public @ResponseBody String filterUsersByScacOrDot(
        @RequestParam(value = "sEcho", required = false, defaultValue = "1") String sEcho,
        @RequestParam(value = "sSearch", required = false) String sSearch,
        @RequestParam(value = "sColumns", required = false) String sColumns,
        @RequestParam(value = "iDisplayStart", required = false, defaultValue = "0") String iDisplayStart,
        @RequestParam(value = "iDisplayLength", required = false, defaultValue = "10") String iDisplayLength,
        @RequestParam(value = "iColumns", required = false, defaultValue = "9") String iColumns,
        @RequestParam(value = "iSortCol_0", required = false, defaultValue = "0") String sortColumnIndex,
        @RequestParam(value = "sSortDir_0", required = false, defaultValue = "asc") String sSortDirection,
        @RequestParam(value = "scacFilter", required = false, defaultValue = "") String scacFilter,
        @RequestParam(value = "dotFilter", required = false, defaultValue = "") String dotFilter,
        @RequestParam(value = "userTypeFilter", required = false, defaultValue = "All") String userTypeFilter,
        @RequestParam(value = "companyNameFilter", required = false, defaultValue = "") String companyNameFilter,
        @RequestParam(value = "firstNameFilter", required = false, defaultValue = "") String firstNameFilter,
        @RequestParam(value = "lastNameFilter", required = false, defaultValue = "") String lastNameFilter,
        @RequestParam(value = "emailFilter", required = false, defaultValue = "") String emailFilter) {

    try {/* w  ww .  j a  va  2s .c o m*/
        Integer userTypeId = 0;

        Map<String, String> filtermap = new HashMap<String, String>();

        if (StringUtils.hasLength(userTypeFilter)) {
            if (userTypeFilter.equalsIgnoreCase("iep")) {
                userTypeId = 2;
            } else if (userTypeFilter.equalsIgnoreCase("mc")) {
                userTypeId = 3;
            } else {
                userTypeId = 0;
            }
        }

        if (StringUtils.hasLength(scacFilter)) {
            filtermap.put("scacFilter", scacFilter + "%");
        }
        if (StringUtils.hasLength(dotFilter)) {
            filtermap.put("dotFilter", dotFilter + "%");
        }
        if (StringUtils.hasLength(companyNameFilter)) {
            filtermap.put("companyNameFilter", companyNameFilter + "%");
        }
        if (StringUtils.hasLength(firstNameFilter)) {
            filtermap.put("firstNameFilter", firstNameFilter + "%");
        }
        if (StringUtils.hasLength(lastNameFilter)) {
            filtermap.put("lastNameFilter", lastNameFilter + "%");
        }
        if (StringUtils.hasLength(emailFilter)) {
            filtermap.put("emailFilter", emailFilter + "%");
        }

        filtermap.put("sortColumnIndex", sortColumnIndex);
        filtermap.put("sSortDirection", sSortDirection);

        List<DverUserVO> dverUsers = this.dverRegistrationService.getFilteredUsersByScacOrDot(userTypeId,
                filtermap, Integer.parseInt(iDisplayStart), Integer.parseInt(iDisplayLength));

        if (CollectionUtils.isEmpty(dverUsers)) {
            dverUsers = new ArrayList<DverUserVO>();
        }

        int iTotalRecords = dverUsers.size();
        int iTotalDisplayRecords = this.dverRegistrationService.countFilteredUsersByScacOrDot(userTypeId,
                filtermap);

        JsonObject jsonResponse = new JsonObject();
        jsonResponse.addProperty("sEcho", sEcho);
        jsonResponse.addProperty("iTotalRecords", iTotalRecords);
        jsonResponse.addProperty("iTotalDisplayRecords", iTotalDisplayRecords);
        Gson gson = new Gson();
        jsonResponse.add("aaData", gson.toJsonTree(dverUsers));
        return jsonResponse.toString();

    } catch (Exception ex) {
        DVERUtil.sendExceptionEmails("filterUsersByScacOrDot method of DverAdminController \n " + ex);
        logger.error("Error in loadUsersByType....." + ex);
        return "error";
    }
}

From source file:org.terasoluna.gfw.functionaltest.app.pagination.PaginationController.java

@RequestMapping(value = { "23_1", "23_1/{page}/{size}", "23_2",
        "23_2/{page}/{size}" }, method = RequestMethod.GET)
public String fuinctionTest_23_x(PersonSearchForm form,
        @PageableDefault(sort = "firstname", direction = Direction.DESC) Pageable pageable, Model model) {

    if (!StringUtils.hasLength(form.getName())) {
        return "pagination/searchPathTmplAndQueryTmplAndCriteriaQuery";
    }/*  ww  w .jav  a  2 s .  co m*/

    Page<Person> page = paginationService.findPersonByName(form.getName(), pageable);

    model.addAttribute("page", page);

    return "pagination/searchPathTmplAndQueryTmplAndCriteriaQuery";
}

From source file:com.apdplat.platform.spring.APDPlatPersistenceUnitReader.java

public void setSharedCacheModeName(String sharedCacheModeName) {
    this.sharedCacheModeName = (StringUtils.hasLength(sharedCacheModeName) ? sharedCacheModeName
            : DEFAULT_SHARED_CACHE_MODE_NAME);
}

From source file:grails.plugin.cache.web.filter.PageFragmentCachingFilter.java

protected PageInfo buildPage(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    // Invoke the next entity in the chain
    SerializableByteArrayOutputStream out = new SerializableByteArrayOutputStream();
    GenericResponseWrapper wrapper = new GenericResponseWrapper(response, out);
    Map<String, Serializable> cacheableRequestAttributes = new HashMap<String, Serializable>();

    // TODO: split the special include handling out into a separate method
    HttpServletResponse originalResponse = null;
    boolean isInclude = WebUtils.isIncludeRequest(request);
    if (isInclude) {
        originalResponse = WrappedResponseHolder.getWrappedResponse();
        WrappedResponseHolder.setWrappedResponse(wrapper);
    }//from   w w w  .  j  a v a  2 s  .  c  om
    try {
        List<String> attributesBefore = toList(request.getAttributeNames());
        chain.doFilter(request, wrapper);
        List<String> attributesAfter = toList(request.getAttributeNames());
        attributesAfter.removeAll(attributesBefore);
        for (String attrName : attributesAfter) {
            Object value = request.getAttribute(attrName);
            if (value instanceof Serializable) {
                cacheableRequestAttributes.put(attrName, (Serializable) value);
            }
        }
    } finally {
        if (isInclude) {
            WrappedResponseHolder.setWrappedResponse(originalResponse);
        }
    }
    wrapper.flush();

    long timeToLiveSeconds = Integer.MAX_VALUE; // TODO cacheManager.getEhcache(context.cacheName).cacheConfiguration.timeToLiveSeconds;

    String contentType = wrapper.getContentType();
    if (!StringUtils.hasLength(contentType)) {
        contentType = response.getContentType();
    }

    return new PageInfo(wrapper.getStatus(), contentType, out.toByteArray(), false, timeToLiveSeconds,
            wrapper.getAllHeaders(), wrapper.getCookies(), cacheableRequestAttributes);
}

From source file:org.smf4j.spring.RegistryNodeTemplateDefinitionParser.java

protected String parseCustom(ParserContext context, Element element, BeanDefinition containingBean) {
    String name = getName(context, element);
    String ref = element.getAttribute(REF_ATTR);

    String customBeanId = null;/*  w  ww .  j a v a  2s  .c o m*/
    if (StringUtils.hasLength(ref)) {
        customBeanId = ref;
    } else {
        // Grab the single child element, that should define or point
        // to the custom Accumulator or Calcuation bean definition.
        NodeList childList = element.getChildNodes();
        Element child = null;
        for (int i = 0; i < childList.getLength(); i++) {
            Node childNode = childList.item(i);
            if (!(childNode instanceof Element)) {
                continue;
            }

            if (child != null) {
                context.getReaderContext()
                        .error("'custom' elements without a 'ref' attribute must "
                                + "have exactly one 'bean', 'ref', or 'idref' child" + " element.",
                                context.extractSource(element));
            }
            child = (Element) childNode;
        }

        if (child == null) {
            context.getReaderContext()
                    .error("'custom' elements must specify a 'ref' attribute or a "
                            + "single 'bean', 'ref', or 'idref' child element.",
                            context.extractSource(element));
        }

        // Parse the contents of the custom bean
        Object o = context.getDelegate().parsePropertySubElement(child, containingBean);

        if (o instanceof BeanDefinitionHolder) {
            BeanDefinitionHolder bdh = (BeanDefinitionHolder) o;
            customBeanId = bdh.getBeanName();
            if (!StringUtils.hasLength(customBeanId)) {
                // They didn't give their bean an id, so we'll need to
                // generate one for it now.
                customBeanId = context.getReaderContext().generateBeanName(bdh.getBeanDefinition());
            }

            // Register this bean
            context.getRegistry().registerBeanDefinition(customBeanId, bdh.getBeanDefinition());
        } else if (o instanceof RuntimeBeanReference) {
            RuntimeBeanReference rbr = (RuntimeBeanReference) o;
            customBeanId = rbr.getBeanName();
        } else if (o instanceof RuntimeBeanNameReference) {
            RuntimeBeanNameReference rbnr = (RuntimeBeanNameReference) o;
            customBeanId = rbnr.getBeanName();
        }
    }

    // Create proxy that associates the given name with this child
    BeanDefinitionBuilder accProxyBdb = getBdb(RegistryNodeChildProxy.class);
    accProxyBdb.addPropertyValue(NAME_ATTR, name);
    accProxyBdb.addPropertyValue(CHILD_ATTR, customBeanId);
    accProxyBdb.getRawBeanDefinition().setSource(element);

    return context.getReaderContext().registerWithGeneratedName(accProxyBdb.getBeanDefinition());
}

From source file:com.apdplat.platform.spring.APDPlatPersistenceUnitReader.java

public void setValidationModeName(String validationModeName) {
    this.validationModeName = (StringUtils.hasLength(validationModeName) ? validationModeName
            : DEFAULT_VALIDATION_MODE_NAME);
}

From source file:org.brekka.stillingar.spring.config.ConfigurationServiceBeanDefinitionParser.java

/**
 * @param element//from  w  w  w  . j  ava  2s .c o m
 * @return
 */
protected AbstractBeanDefinition prepareResourceManager(Element element, Engine engine,
        ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ResourceSnapshotManager.class);
    builder.addConstructorArgValue(prepareResourceSelector(element, engine, parserContext));
    builder.addConstructorArgReference(getLoaderReference(element));
    builder.addConstructorArgValue(prepareResourceMonitor(element));
    Element handlers = selectSingleChildElement(element, "handlers", true);
    if (handlers != null) {
        String rejectedRef = handlers.getAttribute("rejected-ref");
        if (StringUtils.hasLength(rejectedRef)) {
            builder.addPropertyReference("rejectedResourceHandler", rejectedRef);
        }
    }
    return builder.getBeanDefinition();
}