Java Code Examples for org.springframework.util.StringUtils#hasText()
The following examples show how to use
org.springframework.util.StringUtils#hasText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationDrivenBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 6 votes |
private void registerAsyncExecutionAspect(Element element, ParserContext parserContext) { if (!parserContext.getRegistry().containsBeanDefinition(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ASYNC_EXECUTION_ASPECT_CLASS_NAME); builder.setFactoryMethod("aspectOf"); String executor = element.getAttribute("executor"); if (StringUtils.hasText(executor)) { builder.addPropertyReference("executor", executor); } String exceptionHandler = element.getAttribute("exception-handler"); if (StringUtils.hasText(exceptionHandler)) { builder.addPropertyReference("exceptionHandler", exceptionHandler); } parserContext.registerBeanComponent(new BeanComponentDefinition(builder.getBeanDefinition(), TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME)); } }
Example 2
Source File: SysMenuService.java From roncoo-jui-springboot with Apache License 2.0 | 6 votes |
public Page<SysMenuVO> listForPage(int pageCurrent, int pageSize, SysMenuQO qo) { SysMenuExample example = new SysMenuExample(); Criteria c = example.createCriteria(); if (StringUtils.hasText(qo.getMenuName())) { c.andMenuNameEqualTo(qo.getMenuName()); } else { c.andParentIdEqualTo(0L); } example.setOrderByClause(" sort desc, id desc "); Page<SysMenu> page = dao.listForPage(pageCurrent, pageSize, example); Page<SysMenuVO> p = PageUtil.transform(page, SysMenuVO.class); if (!StringUtils.hasText(qo.getMenuName())) { if (CollectionUtil.isNotEmpty(p.getList())) { for (SysMenuVO sm : p.getList()) { sm.setList(recursionList(sm.getId())); } } } return p; }
Example 3
Source File: SendToMethodReturnValueHandler.java From java-technology-stack with MIT License | 6 votes |
protected String[] getTargetDestinations(@Nullable Annotation annotation, Message<?> message, String defaultPrefix) { if (annotation != null) { String[] value = (String[]) AnnotationUtils.getValue(annotation); if (!ObjectUtils.isEmpty(value)) { return value; } } String name = DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER; String destination = (String) message.getHeaders().get(name); if (!StringUtils.hasText(destination)) { throw new IllegalStateException("No lookup destination header in " + message); } return (destination.startsWith("/") ? new String[] {defaultPrefix + destination} : new String[] {defaultPrefix + '/' + destination}); }
Example 4
Source File: AboutController.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
private String getChecksum(String defaultValue, String url, String version) { String result = defaultValue; if (result == null && StringUtils.hasText(url)) { CloseableHttpClient httpClient = HttpClients.custom() .setSSLHostnameVerifier(new NoopHostnameVerifier()) .build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); requestFactory.setHttpClient(httpClient); url = constructUrl(url, version); try { ResponseEntity<String> response = new RestTemplate(requestFactory).exchange( url, HttpMethod.GET, null, String.class); if (response.getStatusCode().equals(HttpStatus.OK)) { result = response.getBody(); } } catch (HttpClientErrorException httpException) { // no action necessary set result to undefined logger.debug("Didn't retrieve checksum because", httpException); } } return result; }
Example 5
Source File: DataDictionaryListServiceImpl.java From roncoo-adminlte-springmvc with Apache License 2.0 | 6 votes |
@Override public Result<Page<RcDataDictionaryList>> listForPage(int pageCurrent, int pageSize, String fieldCode, String premise, String datePremise) { Result<Page<RcDataDictionaryList>> result = new Result<>(); if (pageCurrent < 1) { result.setErrMsg("参数pageCurrent有误,pageCurrent=" + pageCurrent); return result; } if (pageSize < 1) { result.setErrMsg("参数pageSize有误,pageSize=" + pageSize); return result; } if (!StringUtils.hasText(fieldCode)) { result.setErrMsg("fieldCode不能为空"); return result; } Page<RcDataDictionaryList> resultData = dao.listForPage(pageCurrent, pageSize, fieldCode, premise, datePremise); result.setResultData(resultData); result.setStatus(true); result.setErrCode(0); return result; }
Example 6
Source File: DateUtils.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * String类型 转换为Date, 如果参数长度为10 转换格式”yyyy-MM-dd“ 如果参数长度为19 转换格式”yyyy-MM-dd * HH:mm:ss“ * @param text String类型的时间值 */ @Override public void setAsText(String text) throws IllegalArgumentException { if (StringUtils.hasText(text)) { try { if (text.indexOf(":") == -1 && text.length() == 10) { setValue(DateUtils.date_sdf.get().parse(text)); } else if (text.indexOf(":") > 0 && text.length() == 19) { setValue(DateUtils.datetimeFormat.get().parse(text)); } else { throw new IllegalArgumentException("Could not parse date, date format is error "); } } catch (ParseException ex) { IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage()); iae.initCause(ex); throw iae; } } else { setValue(null); } }
Example 7
Source File: DataTabInterceptor.java From bdf3 with Apache License 2.0 | 5 votes |
public void onInit(DefaultEntityDataType dataTypeData) throws Exception { DoradoContext dc = DoradoContext.getCurrent(); String dbInfoId = (String) dc.getAttribute(DoradoContext.VIEW, "dbInfoId"); String tableName = (String) dc.getAttribute(DoradoContext.VIEW, "tableName"); String sql = (String) dc.getAttribute(DoradoContext.VIEW, "sql"); String type = (String) dc.getAttribute(DoradoContext.VIEW, "type"); List<ColumnInfo> columns = null; if (type.equals(SIMPLE_TYPE)) { if (StringUtils.hasText(tableName)) { columns = dbService.findColumnInfos(dbInfoId, tableName); } } else { columns = dbService.findMultiColumnInfos(dbInfoId, sql); } DataTypeManager dataTypeManager = (DataTypeManager) DoradoContext.getCurrent().getServiceBean("dataTypeManager"); BasePropertyDef pd; if (columns != null) { for (ColumnInfo info : columns) { pd = new BasePropertyDef(); PropertyDef propertyDef = dataTypeData.getPropertyDef(info.getColumnName()); if (propertyDef != null) { continue; } pd.setName(info.getColumnName()); log.debug(String.format("datagrid[columnName=%s,columnType=%s]", info.getColumnName(), info.getColumnType())); String doradoType = ColumnTypeUtils.getDroadoType(info); if (StringUtils.hasText(doradoType)) { pd.setDataType(dataTypeManager.getDataType(doradoType)); } if (type.equals(SIMPLE_TYPE)) { if (info.isIsnullAble()) { pd.setRequired(false); } else { pd.setRequired(true); } } dataTypeData.addPropertyDef(pd); } } }
Example 8
Source File: JpaUserDetails.java From eds-starter6-jpa with Apache License 2.0 | 5 votes |
public JpaUserDetails(User user) { this.userDbId = user.getId(); this.password = user.getPasswordHash(); this.loginName = user.getLoginName(); this.enabled = user.isEnabled(); if (StringUtils.hasText(user.getLocale())) { this.locale = new Locale(user.getLocale()); } else { this.locale = Locale.ENGLISH; } this.locked = user.getLockedOutUntil() != null && user.getLockedOutUntil().isAfter(ZonedDateTime.now(ZoneOffset.UTC)); this.userAuthorities = user.getAuthorities(); if (StringUtils.hasText(user.getSecret())) { this.authorities = Collections.unmodifiableCollection( AuthorityUtils.createAuthorityList("PRE_AUTH")); } else { this.authorities = Collections.unmodifiableCollection(AuthorityUtils .commaSeparatedStringToAuthorityList(user.getAuthorities())); } }
Example 9
Source File: CachingResourceResolver.java From java-technology-stack with MIT License | 5 votes |
protected String computeKey(@Nullable HttpServletRequest request, String requestPath) { StringBuilder key = new StringBuilder(RESOLVED_RESOURCE_CACHE_KEY_PREFIX); key.append(requestPath); if (request != null) { String codingKey = getContentCodingKey(request); if (StringUtils.hasText(codingKey)) { key.append("+encoding=").append(codingKey); } } return key.toString(); }
Example 10
Source File: EntityManagerFactoryServiceImpl.java From multitenant with Apache License 2.0 | 5 votes |
private String[] mergePackagesToScan() { String[] packages = null; if (StringUtils.hasText(packagesToScan) && StringUtils.hasText(customPackagesToScan)) { packages = (packagesToScan + "," + customPackagesToScan).split(","); } else if (StringUtils.hasText(packagesToScan)) { packages = packagesToScan.split(","); } else if (StringUtils.hasText(customPackagesToScan)) { packages = customPackagesToScan.split(","); } return packages; }
Example 11
Source File: DataDictionaryListServiceImpl.java From roncoo-adminlte-springmvc with Apache License 2.0 | 5 votes |
@Override public Result<String> deleteByFieldCode(String fieldCode) { Result<String> result = new Result<>(); if (!StringUtils.hasText(fieldCode)) { result.setErrMsg("fieldCode不能为空"); return result; } dao.deleteByFieldCode(fieldCode); result.setStatus(true); result.setErrCode(0); return result; }
Example 12
Source File: EncryptOnePm.java From pgptool with GNU General Public License v3.0 | 5 votes |
protected void refreshPrimaryOperationAvailability() { boolean result = true; result &= !selectedRecipients.getList().isEmpty(); result &= StringUtils.hasText(sourceFile.getValue()) && new File(sourceFile.getValue()).exists(); result &= isUseSameFolder.getValue() || StringUtils.hasText(targetFile.getValue()); actionDoOperation.setEnabled(result); }
Example 13
Source File: StubMapperProperties.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
public String fromIvyNotationToId(String ivyNotation) { StubConfiguration stubConfiguration = new StubConfiguration(ivyNotation); String id = this.idsToServiceIds.get(ivyNotation); if (StringUtils.hasText(id)) { return id; } String groupAndArtifact = this.idsToServiceIds.get( stubConfiguration.getGroupId() + ":" + stubConfiguration.getArtifactId()); if (StringUtils.hasText(groupAndArtifact)) { return groupAndArtifact; } return this.idsToServiceIds.get(stubConfiguration.getArtifactId()); }
Example 14
Source File: AbstractHeaderMapper.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Generate the name to use to set the header defined by the specified * {@code propertyName} to the {@link MessageHeaders} instance. * @see #setInboundPrefix(String) */ protected String toHeaderName(String propertyName) { String headerName = propertyName; if (StringUtils.hasText(this.inboundPrefix) && !headerName.startsWith(this.inboundPrefix)) { headerName = this.inboundPrefix + propertyName; } return headerName; }
Example 15
Source File: DashboardViewDescriptor.java From jenkins-deployment-dashboard-plugin with MIT License | 4 votes |
public FormValidation doCheckPassword(@QueryParameter final String password) { if (StringUtils.hasText(password)) { return FormValidation.ok(); } return FormValidation.warning(Messages.DashboardView_artifactoryPassword()); }
Example 16
Source File: DataFlowConfiguration.java From composed-task-runner with Apache License 2.0 | 4 votes |
/** * @param clientRegistrations Can be null. Only required for Client Credentials Grant authentication * @param clientCredentialsTokenResponseClient Can be null. Only required for Client Credentials Grant authentication * @return DataFlowOperations */ @Bean public DataFlowOperations dataFlowOperations( @Autowired(required = false) ClientRegistrationRepository clientRegistrations, @Autowired(required = false) OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> clientCredentialsTokenResponseClient) { final RestTemplate restTemplate = DataFlowTemplate.getDefaultDataflowRestTemplate(); validateUsernamePassword(this.properties.getDataflowServerUsername(), this.properties.getDataflowServerPassword()); HttpClientConfigurer clientHttpRequestFactoryBuilder = null; if (this.properties.getOauth2ClientCredentialsClientId() != null || StringUtils.hasText(this.properties.getDataflowServerAccessToken()) || (StringUtils.hasText(this.properties.getDataflowServerUsername()) && StringUtils.hasText(this.properties.getDataflowServerPassword()))) { clientHttpRequestFactoryBuilder = HttpClientConfigurer.create(this.properties.getDataflowServerUri()); } String accessTokenValue = null; if (this.properties.getOauth2ClientCredentialsClientId() != null) { final ClientRegistration clientRegistration = clientRegistrations.findByRegistrationId("default"); final OAuth2ClientCredentialsGrantRequest grantRequest = new OAuth2ClientCredentialsGrantRequest(clientRegistration); final OAuth2AccessTokenResponse res = clientCredentialsTokenResponseClient.getTokenResponse(grantRequest); accessTokenValue = res.getAccessToken().getTokenValue(); logger.debug("Configured OAuth2 Client Credentials for accessing the Data Flow Server"); } else if (StringUtils.hasText(this.properties.getDataflowServerAccessToken())) { accessTokenValue = this.properties.getDataflowServerAccessToken(); logger.debug("Configured OAuth2 Access Token for accessing the Data Flow Server"); } else if (StringUtils.hasText(this.properties.getDataflowServerUsername()) && StringUtils.hasText(this.properties.getDataflowServerPassword())) { accessTokenValue = null; clientHttpRequestFactoryBuilder.basicAuthCredentials(properties.getDataflowServerUsername(), properties.getDataflowServerPassword()); logger.debug("Configured basic security for accessing the Data Flow Server"); } else { logger.debug("Not configuring basic security for accessing the Data Flow Server"); } if (accessTokenValue != null) { restTemplate.getInterceptors().add(new OAuth2AccessTokenProvidingClientHttpRequestInterceptor(accessTokenValue)); } if (clientHttpRequestFactoryBuilder != null) { restTemplate.setRequestFactory(clientHttpRequestFactoryBuilder.buildClientHttpRequestFactory()); } return new DataFlowTemplate(this.properties.getDataflowServerUri(), restTemplate); }
Example 17
Source File: RequestLoggingFilter.java From herd with Apache License 2.0 | 4 votes |
/** * Log the request message. * * @param request the request. */ public void logRequest(HttpServletRequest request) { StringBuilder message = new StringBuilder(); // Append the log message prefix. message.append(logMessagePrefix); // Append the URI. message.append("uri=").append(request.getRequestURI()); // Append the query string if present. if (isIncludeQueryString() && StringUtils.hasText(request.getQueryString())) { message.append('?').append(request.getQueryString()); } // Append the HTTP method. message.append(";method=").append(request.getMethod()); // Append the client information. if (isIncludeClientInfo()) { // The client remote address. String client = request.getRemoteAddr(); if (StringUtils.hasLength(client)) { message.append(";client=").append(client); } // The HTTP session information. HttpSession session = request.getSession(false); if (session != null) { message.append(";session=").append(session.getId()); } // The remote user information. String user = request.getRemoteUser(); if (user != null) { message.append(";user=").append(user); } } // Get the request payload. String payloadString = ""; try { if (payload != null && payload.length > 0) { payloadString = new String(payload, 0, payload.length, getCharacterEncoding()); } } catch (UnsupportedEncodingException e) { payloadString = "[Unknown]"; } // Append the request payload if present. if (isIncludePayload() && StringUtils.hasLength(payloadString)) { String sanitizedPayloadString = HerdStringUtils.sanitizeLogText(payloadString); message.append(";payload=").append(sanitizedPayloadString); } // Append the log message suffix. message.append(logMessageSuffix); // Log the actual message. LOGGER.debug(message.toString()); }
Example 18
Source File: TracingJdbcEventListener.java From spring-boot-data-source-decorator with Apache License 2.0 | 4 votes |
private String getSql(StatementInformation statementInformation) { return includeParameterValues && StringUtils.hasText(statementInformation.getSqlWithValues()) ? statementInformation.getSqlWithValues() : statementInformation.getSql(); }
Example 19
Source File: RequestParamMapMethodArgumentResolver.java From java-technology-stack with MIT License | 4 votes |
private boolean allParams(RequestParam requestParam, Class<?> type) { return (Map.class.isAssignableFrom(type) && !StringUtils.hasText(requestParam.name())); }
Example 20
Source File: CloudMongoDbFactoryParser.java From spring-cloud-connectors with Apache License 2.0 | 4 votes |
private void parseWriteConcern(Element element, Map<String, String> attributeMap) { String writeConcern = element.getAttribute(WRITE_CONCERN); if (StringUtils.hasText(writeConcern)) { attributeMap.put(WRITE_CONCERN, writeConcern); } }