List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:org.trpr.platform.spi.task.TaskData.java
/** * Adds the specified entity data to this TaskData * @param entity the data for task execution */// ww w . j a v a 2 s . c o m public void addEntity(T... entities) { for (T entity : entities) { // if entity name is not specified, set the fully qualified class name as the entity name entity.setEntityName(StringUtils.hasLength(entity.getEntityName()) ? entity.getEntityName() : entity.getClass().getName()); this.entitiesList.add(entity); } }
From source file:com.cloudbees.demo.beesshop.product.ProductRepository.java
/** * @param name//from w w w . ja v a 2s. c o m * @return */ public Collection<Product> find(@Nullable String name) { SortedSet<Product> result = new TreeSet<Product>(); for (Product product : products.values()) { if (name == null && name == null) { result.add(product); } if (StringUtils.hasLength(name)) { if (product.getName().toLowerCase().contains(name.toLowerCase())) { result.add(product); break; } } } return result; }
From source file:org.openmrs.module.feedback.web.AddStatusFormController.java
@Override protected String formBackingObject(HttpServletRequest request) throws Exception { String text = "Not Used"; Boolean feedbackMessage = false; String status = request.getParameter("status"); /* To make sure that the status is neither NULL nor empty */ if ((status != null) && StringUtils.hasLength(status)) { Object o = Context.getService(FeedbackService.class); FeedbackService service = (FeedbackService) o; Status x = new Status(); /** This makes sure that the status value always remain less then or equal to 50 */ x.setStatus(status);//from w ww. ja va 2s . c om service.saveStatus(x); request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "feedback.notification.status.added"); } log.debug("Returning hello world text: " + text); return text; }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.facebook.FacebookLogoutHandler.java
/** * {@inheritDoc}//from www . ja va 2s .c o m * @see org.springframework.security.ui.logout.LogoutHandler#logout( * javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, * org.springframework.security.Authentication) */ public void logout(final HttpServletRequest request, final HttpServletResponse response, final Authentication authentication) { Cookie[] cookies = request.getCookies(); if (cookies != null) { String path = StringUtils.hasLength(request.getContextPath()) ? request.getContextPath() : "/"; for (Cookie cookie : cookies) { if (cookie.getName().startsWith(_apiKey)) { cancelCookie(cookie.getName(), path, response); } } } }
From source file:uiak.exper.gisamt.jpa.service.CityServiceImpl.java
@Override public Page<City> findCities(CitySearchCriteria criteria, Pageable pageable) { Assert.notNull(criteria, "Criteria must not be null"); String name = criteria.getName(); if (!StringUtils.hasLength(name)) { return this.cityRepository.findAll((Pageable) null); }/*from ww w . j a v a 2 s .c o m*/ String country = ""; int splitPos = name.lastIndexOf(","); if (splitPos >= 0) { country = name.substring(splitPos + 1); name = name.substring(0, splitPos); } return this.cityRepository.findByNameContainingAndCountryContainingAllIgnoringCase(name.trim(), country.trim(), pageable); }
From source file:org.openmrs.module.feedback.web.forwardFeedbackFormController.java
@Override protected Map referenceData(HttpServletRequest req) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); String feedbackId = req.getParameter("feedbackId"); /* Make sure that the feedback ID is not empty */ if (StringUtils.hasLength(feedbackId)) { try {//w ww .j a va2s . c o m FeedbackService hService = (FeedbackService) Context.getService(FeedbackService.class); /* This return the feedback object and status to the feedbackform page. */ map.put("feedback", hService.getFeedback((Integer.parseInt(req.getParameter("feedbackId"))))); } catch (Exception exception) { log.error(exception); map.put("feedback", new Feedback()); } } return map; }
From source file:edu.uchicago.duo.security.DuoAuthenticationDetailsSource.java
@Override public GrantedAuthoritiesContainer buildDetails(HttpServletRequest request) { List gal = new ArrayList(); try {//from w w w . j a v a2 s . com GrantedAuthority ga = null; if (StringUtils.hasLength(request.getHeader("uid"))) { ga = new SimpleGrantedAuthority("ROLE_USER"); } else { ga = new SimpleGrantedAuthority("ROLE_ANONYMOUS"); } log.debug("UID=" + request.getHeader("uid") + "|Granted:" + ga); gal.add(ga); } catch (Exception e) { throw new AuthenticationServiceException("Error..", e); } return new PreAuthenticatedGrantedAuthoritiesWebAuthenticationDetails(request, gal); }
From source file:com.example.securelogin.app.common.validation.DomainRestrictedURLValidator.java
@Override public boolean isValid(CharSequence value, ConstraintValidatorContext context) { Matcher urlMatcher = URL_REGEX.matcher(value); if (urlMatcher.matches()) { String host = urlMatcher.group(1); for (String domain : allowedDomains) { if (StringUtils.hasLength(host) && host.endsWith("." + domain)) { return true; }//from www . j a va 2s.com } return false; } else { return true; } }
From source file:org.smf4j.spring.FileEnablerBeanDefinitionParser.java
@Override protected void doParse(Element element, ParserContext context, BeanDefinitionBuilder builder) { List<String> paths = new ArrayList<String>(); String path = element.getAttribute(PATH_ATTR); if (StringUtils.hasLength(path)) { paths.add(path);/* w ww.j a va2 s . c o m*/ } List<Element> pathElements = DomUtils.getChildElementsByTagName(element, PATH_TAG); for (Element pathElement : pathElements) { path = pathElement.getAttribute(VALUE_ATTR); if (StringUtils.hasLength(path)) { paths.add(path); } } builder.addPropertyValue(PATHS_ATTR, paths); builder.setLazyInit(false); }
From source file:org.openmrs.module.feedback.web.AddPredefinedSubjectFormController.java
@Override protected Boolean formBackingObject(HttpServletRequest request) throws Exception { Boolean feedbackMessage = false; String sortWeight = request.getParameter("sortWeight"); String predefinedSubject = request.getParameter("predefinedsubject"); /* The Subject can't be NULL or an empty string */ if (StringUtils.hasLength(predefinedSubject)) { Object o = Context.getService(FeedbackService.class); FeedbackService service = (FeedbackService) o; PredefinedSubject s = new PredefinedSubject(); if (!StringUtils.hasLength(sortWeight) || (sortWeight == null)) { s.setSortWeight(0);/*from w w w. j a v a 2 s .c om*/ s.setSubject(predefinedSubject); service.savePredefinedSubject(s); /** * Notifies to the Controller that the predefined subject has been successfully added * with the help of get feedbackPageMessage param */ request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "feedback.notification.predefinedSubject.added"); } else if (isInt(sortWeight)) { s.setSortWeight(Integer.parseInt(sortWeight)); s.setSubject(predefinedSubject); service.savePredefinedSubject(s); /** * Notifies to the Controller that the predefined subject has been successfully added * with the help of get feedbackPageMessage param */ request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "feedback.notification.predefinedSubject.added"); } else { request.getSession().setAttribute(WebConstants.OPENMRS_MSG_ATTR, "feedback.notification.number.error"); } /** This makes sure that the Predefined Subject value always remain less then or equal to 50 */ } return feedbackMessage; }