List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:org.jasypt.spring31.xml.encryption.EncryptablePropertyOverrideBeanDefinitionParser.java
@Override protected void doParse(final Element element, final BeanDefinitionBuilder builder) { super.doParse(element, builder); builder.addPropertyValue("ignoreInvalidKeys", Boolean.valueOf(element.getAttribute("ignore-unresolvable"))); final String encryptorBeanName = element.getAttribute(ENCRYPTOR_ATTRIBUTE); if (StringUtils.hasText(encryptorBeanName)) { builder.addConstructorArgReference(encryptorBeanName); }/*ww w. j a v a2 s. co m*/ }
From source file:com.shopzilla.spring.util.config.ShopzillaNamespaceUtils.java
/** * Populates the specified bean definition property with the value of the attribute whose name is provided if that attribute is defined in the given element. * * @param builder the bean definition to be configured * @param element the XML element where the attribute should be defined * @param attributeName the name of the attribute whose value will be used to populate the property * @param propertyName the name of the property to be populated *//*from w w w . jav a 2 s.c om*/ public void setValueIfAttributeDefined(BeanDefinitionBuilder builder, Element element, String attributeName, String propertyName) { String attributeValue = element.getAttribute(attributeName); if (StringUtils.hasText(attributeValue)) { builder.addPropertyValue(propertyName, attributeValue); } }
From source file:io.pivotal.spring.xd.jdbcgpfdist.support.LoadConfigurationFactoryBean.java
@Override public void afterPropertiesSet() throws Exception { if (controlFile != null) { if (controlFile.getGploadOutputMode() != null) { if (controlFile.getGploadOutputMode() == ControlFile.OutputMode.INSERT) { mode = Mode.INSERT;//from w ww.ja va 2s . co m } else if (controlFile.getGploadOutputMode() == ControlFile.OutputMode.UPDATE) { mode = Mode.UPDATE; } } if (StringUtils.hasText(controlFile.getGploadOutputTable())) { table = controlFile.getGploadOutputTable(); } if (controlFile.getGploadOutputMatchColumns() != null) { matchColumns = controlFile.getGploadOutputMatchColumns(); } if (controlFile.getGploadOutputUpdateColumns() != null) { updateColumns = controlFile.getGploadOutputUpdateColumns(); } if (StringUtils.hasText(controlFile.getGploadOutputUpdateCondition())) { updateCondition = controlFile.getGploadOutputUpdateCondition(); } if (!controlFile.getGploadSqlBefore().isEmpty()) { sqlBefore = controlFile.getGploadSqlBefore(); } if (!controlFile.getGploadSqlAfter().isEmpty()) { sqlAfter = controlFile.getGploadSqlAfter(); } } }
From source file:org.apache.geode.geospatial.utils.ToolBox.java
public static Properties testAndSetProperty(Properties properties, String property, String value) { if (properties != null && StringUtils.hasText(value)) { properties.setProperty(property, value); }//from w w w.ja va 2 s.co m return properties; }
From source file:com.gradecak.alfresco.mvc.aop.RunAsAdvice.java
public Object invoke(final MethodInvocation invocation) throws Throwable { Class<?> targetClass = invocation.getThis() != null ? invocation.getThis().getClass() : null; Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass); // If we are dealing with method with generic parameters, find the original // method.//from w ww . ja v a 2 s . com specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); AlfrescoRunAs alfrescounRunAs = parseRunAsAnnotation(specificMethod); if (alfrescounRunAs != null) { String runAs = alfrescounRunAs.value(); if (StringUtils.hasText(runAs)) { RunAsWork<Object> getUserNameRunAsWork = new RunAsWork<Object>() { public Object doWork() throws Exception { try { return invocation.proceed(); } catch (Throwable e) { throw new Exception(e.getMessage(), e); } } }; return AuthenticationUtil.runAs(getUserNameRunAsWork, runAs); } } return invocation.proceed(); }
From source file:org.springdata.ehcache.config.xml.TemplateParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String cacheManagerRef = element.getAttribute("cache-manager-ref"); if (!StringUtils.hasText(cacheManagerRef)) { cacheManagerRef = ConfigConstants.CACHE_MANAGER_DEFAULT_ID; }/*from w ww. jav a 2s.co m*/ builder.addPropertyReference("cacheManager", cacheManagerRef); String converterRef = element.getAttribute("converter-ref"); if (!StringUtils.hasText(converterRef)) { converterRef = ConfigConstants.CONVERTER_DEFAULT_ID; } builder.addPropertyReference("ehcacheConverter", converterRef); postProcess(builder, element); }
From source file:org.opencredo.couchdb.config.CouchDbUrlToDocumentTransformerParser.java
@Override protected void parseTransformer(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { System.out.println("CouchDbUrlToDocumentTransformerParser2"); String documentType = element.getAttribute(COUCHDB_DOCUMENT_TYPE_ATTRIBUTE); String documentOperations = element.getAttribute(COUCHDB_DOCUMENT_OPERATIONS_ATTRIBUTE); if (!StringUtils.hasText(documentType)) { parserContext.getReaderContext().error("The '" + COUCHDB_DOCUMENT_TYPE_ATTRIBUTE + "' is mandatory.", parserContext.extractSource(element)); } else {/*from w w w .j a v a2 s.c o m*/ builder.addConstructorArgValue(documentType); } if (StringUtils.hasText(documentOperations)) { builder.addConstructorArgReference(documentOperations); } }
From source file:org.springdata.ehcache.config.xml.CacheManagerParser.java
@Override protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { String ehcacheFile = element.getAttribute("ehcache"); if (StringUtils.hasText(ehcacheFile)) { builder.addPropertyValue("configFile", ehcacheFile); }/* w w w . j av a2 s . co m*/ String licenseFile = element.getAttribute("license"); if (StringUtils.hasText(licenseFile)) { builder.addPropertyValue("terracottaLicenseFile", licenseFile); } postProcess(builder, element); }
From source file:csns.web.validator.AddUserValidator.java
@Override public void validate(Object target, Errors errors) { User user = (User) target;// w w w.j a v a 2 s . c om Long id = user.getId(); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "error.field.required"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "cin", "error.field.required"); String cin = user.getCin(); if (StringUtils.hasText(cin)) { User u = userDao.getUserByCin(cin); if (u != null && !u.getId().equals(id)) errors.rejectValue("cin", "error.user.cin.taken"); } String primaryEmail = user.getPrimaryEmail(); if (StringUtils.hasText(primaryEmail)) { User u = userDao.getUserByEmail(primaryEmail); if (u != null && !u.getId().equals(id)) errors.rejectValue("primaryEmail", "error.user.email.taken"); } }
From source file:biz.c24.io.spring.batch.config.TransformItemProcessorParser.java
@Override protected void doParse(Element element, BeanDefinitionBuilder builder) { // Mandatory/*from ww w .j a va 2s . c o m*/ String transformId = element.getAttribute("transform-ref"); builder.addPropertyReference("transformer", transformId); // Optional String validate = element.getAttribute("validate"); if (StringUtils.hasText(validate)) { builder.addPropertyValue("validation", validate); } // Optional String failfast = element.getAttribute("failfast"); if (StringUtils.hasText(failfast)) { boolean val = Boolean.parseBoolean(failfast); builder.addPropertyValue("failfast", val); } // Optional String targetClass = element.getAttribute("target-class"); if (StringUtils.hasText(targetClass)) { builder.addPropertyValue("targetClass", targetClass); } }