List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:org.wallride.service.AuthorizedUserDetailsService.java
@Override public UserDetails loadUserByUsername(final String username) throws UsernameNotFoundException, DataAccessException { if (!StringUtils.hasText(username)) { throw new UsernameNotFoundException("Username is empty"); }//from ww w.j a va 2 s .c o m User user; if (!username.contains("@")) { user = userRepository.findOneByLoginId(username); } else { user = userRepository.findOneByEmail(username); } if (user == null) { throw new UsernameNotFoundException("User ID not existing. [" + username + "]"); } return new AuthorizedUser(user); }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.GreenplumDataSourceFactoryBean.java
@Override public void afterPropertiesSet() throws Exception { if (controlFile != null) { if (StringUtils.hasText(controlFile.getHost())) { dbHost = controlFile.getHost(); }// ww w . j a v a2 s . c o m if (StringUtils.hasText(controlFile.getDatabase())) { dbName = controlFile.getDatabase(); } if (StringUtils.hasText(controlFile.getUser())) { dbUser = controlFile.getUser(); } if (StringUtils.hasText(controlFile.getPassword())) { dbPassword = controlFile.getPassword(); } if (controlFile.getPort() != null) { dbPort = controlFile.getPort(); } } super.afterPropertiesSet(); }
From source file:de.tudarmstadt.ukp.dkpro.bigdata.io.hadoop.HdfsResource.java
HdfsResource(String parent, String child, FileSystem fs) { this(StringUtils.hasText(child) ? new Path(new Path(URI.create(parent)), new Path(URI.create(child))) : new Path(URI.create(parent)), fs); }
From source file:org.shept.persistence.provider.hibernate.HibernateCriteriaFilter.java
/** * @return a default criteria definition by simply return an empty entity object * @see http://stackoverflow.com/questions/1926618/hibernate-sort-by-properties-of-inner-bean * /*from w ww.ja v a 2 s .c o m*/ */ public DetachedCriteria getCriteria(SortDefinition sortDefinition) { SortDefinition sd = defaultSortDefinition; DetachedCriteria crit = DetachedCriteria.forClass(getEntityClass()); // set sort criteria from FormFilter if (null != sortDefinition && StringUtils.hasText(sortDefinition.getProperty())) { sd = sortDefinition; } if (null != sd && StringUtils.hasText(sd.getProperty())) { String prop = sd.getProperty(); String[] pathArr = StringUtils.split(prop, "."); if (pathArr == null) { pathArr = new String[] { prop }; } if (pathArr.length > 2) { throw new UnsupportedOperationException( "Sort Criteria Definition '" + prop + "' may only nest one level deep"); } if (pathArr.length == 2) { crit.createAlias(pathArr[0], pathArr[0]); } if (sortDefinition.isAscending()) crit.addOrder(Order.asc(prop)); else crit.addOrder(Order.desc(prop)); } return crit; }
From source file:io.spring.initializr.web.autoconfigure.CloudfoundryEnvironmentPostProcessor.java
@Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication springApplication) { Map<String, Object> map = new LinkedHashMap<>(); String uri = environment.getProperty("vcap.services.stats-index.credentials.uri"); if (StringUtils.hasText(uri)) { UriComponents uriComponents = UriComponentsBuilder.fromUriString(uri).build(); String userInfo = uriComponents.getUserInfo(); if (StringUtils.hasText(userInfo)) { String[] credentials = userInfo.split(":"); map.put("initializr.stats.elastic.username", credentials[0]); map.put("initializr.stats.elastic.password", credentials[1]); }/*from www. j a va 2 s . c o m*/ map.put("initializr.stats.elastic.uri", UriComponentsBuilder.fromUriString(uri).userInfo(null).build().toString()); addOrReplace(environment.getPropertySources(), map); } }
From source file:egov.data.hibernate.repository.support.HibernateEntityInformationSupport.java
public String getEntityName() { Class<?> domainClass = getJavaType(); Entity entity = domainClass.getAnnotation(Entity.class); boolean hasName = null != entity && StringUtils.hasText(entity.name()); return hasName ? entity.name() : domainClass.getSimpleName(); }
From source file:at.porscheinformatik.common.spring.web.extended.template.BaseTemplate.java
public String render() throws IOException { logger.debug("Thread " + Thread.currentThread().getName() + " obtains readLock for template " + getName()); readLock.lock();//from ww w.j a v a2 s . c o m try { String template = getContent(); if (!StringUtils.hasText(template)) { return template; } return template; } finally { logger.debug( "Thread " + Thread.currentThread().getName() + " releases readLock for template " + getName()); readLock.unlock(); } }
From source file:com.reactivetechnologies.platform.datagrid.util.EntityFinder.java
/** * /*w w w.ja va2 s .c om*/ * @param basePkg * @return * @throws ClassNotFoundException */ public static Collection<Class<?>> findEntityClasses(String basePkg) throws ClassNotFoundException { ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider( false); provider.addIncludeFilter(new TypeFilter() { @Override public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException { AnnotationMetadata aMeta = metadataReader.getAnnotationMetadata(); return aMeta.hasAnnotation(HzMapConfig.class.getName()); } }); //consider the finder class to be in the root package Set<BeanDefinition> beans = null; try { beans = provider.findCandidateComponents(StringUtils.hasText(basePkg) ? basePkg : EntityFinder.class.getName().substring(0, EntityFinder.class.getName().lastIndexOf("."))); } catch (Exception e) { throw new IllegalArgumentException("Unable to scan for entities under base package", e); } Set<Class<?>> classes = new HashSet<>(); if (beans != null && !beans.isEmpty()) { classes = new HashSet<>(beans.size()); for (BeanDefinition bd : beans) { classes.add(Class.forName(bd.getBeanClassName())); } } else { log.warn(">> Did not find any key value entities under the given base scan package [" + basePkg + "]"); } return classes; }
From source file:org.jasypt.spring31.xml.encryption.AbstractEncryptionBeanDefinitionParser.java
protected final void processIntegerAttribute(final Element element, final BeanDefinitionBuilder builder, final String attributeName, final String propertyName) { final String attributeValue = element.getAttribute(attributeName); if (StringUtils.hasText(attributeValue)) { try {//w ww. j av a 2 s . c o m final Integer attributeIntegerValue = Integer.valueOf(attributeValue); builder.addPropertyValue(propertyName, attributeIntegerValue); } catch (final NumberFormatException e) { throw new NumberFormatException( "Config attribute \"" + attributeName + "\" is not a valid integer"); } } }