List of usage examples for org.springframework.util StringUtils commaDelimitedListToStringArray
public static String[] commaDelimitedListToStringArray(@Nullable String str)
From source file:org.cloudfoundry.identity.uaa.config.EnvironmentMapFactoryBeanTests.java
private Map<String, ?> getProperties(String input) { HashMap<String, Object> result = new HashMap<String, Object>(); Properties properties = StringUtils .splitArrayElementsIntoProperties(StringUtils.commaDelimitedListToStringArray(input), "="); for (Enumeration<?> keys = properties.propertyNames(); keys.hasMoreElements();) { String key = (String) keys.nextElement(); result.put(key, properties.getProperty(key)); }//from ww w . j a v a 2s . co m return result; }
From source file:org.springmodules.cache.provider.ehcache.EhCacheFlushingModel.java
/** * Sets the names of the caches to flush. * * @param csvCacheNames a comma-separated list of Strings containing the names of the * caches to flush. *//*from w ww. j a v a2s . c om*/ public void setCacheNames(String csvCacheNames) { String[] newCacheNames = null; if (csvCacheNames != null) { newCacheNames = StringUtils.commaDelimitedListToStringArray(csvCacheNames); } setCacheNames(newCacheNames); }
From source file:fr.xebia.springframework.security.core.userdetails.ExtendedUser.java
public void setAllowedRemoteAddresses(String allowedRemoteAddresses) { allowedRemoteAddresses = StringUtils.replace(allowedRemoteAddresses, ";", ","); String[] allowedRemoteAddressesAsArray = StringUtils .commaDelimitedListToStringArray(allowedRemoteAddresses); List<Pattern> newAllowedRemoteAddresses = new ArrayList<Pattern>(); for (String allowedRemoteAddress : allowedRemoteAddressesAsArray) { allowedRemoteAddress = StringUtils.trimWhitespace(allowedRemoteAddress); try {/*from ww w . j av a 2s. c o m*/ newAllowedRemoteAddresses.add(Pattern.compile(allowedRemoteAddress)); } catch (PatternSyntaxException e) { throw new RuntimeException("Exception parsing allowedRemoteAddress '" + allowedRemoteAddress + "' for user '" + this.getUsername() + "'", e); } } this.allowedRemoteAddresses = newAllowedRemoteAddresses; }
From source file:net.phoenix.thrift.xml.ArgBeanDefinitionParser.java
/** * register to the bean factory;// w w w. j a va2 s . c om * * @param element * @param parserContext * @param current */ private void registerBeanDefinition(Element element, ParserContext parserContext, AbstractBeanDefinition current) { try { Element parent = (Element) element.getParentNode(); String argsBeanDefinitionName = parent.getAttribute("id"); String name = argsBeanDefinitionName + "-" + element.getAttribute("name"); String[] alias = null; if (StringUtils.hasLength(name)) { alias = StringUtils.trimArrayElements(StringUtils.commaDelimitedListToStringArray(name)); } BeanDefinitionHolder holder = new BeanDefinitionHolder(current, name, alias); registerBeanDefinition(holder, parserContext.getRegistry()); } catch (BeanDefinitionStoreException ex) { parserContext.getReaderContext().error(ex.getMessage(), element); } }
From source file:com.beyondjservlet.gateway.velocity.SpringResourceLoader.java
@Override public void init(ExtendedProperties configuration) { this.resourceLoader = (org.springframework.core.io.ResourceLoader) this.rsvc .getApplicationAttribute(SPRING_RESOURCE_LOADER); String resourceLoaderPath = (String) this.rsvc.getApplicationAttribute(SPRING_RESOURCE_LOADER_PATH); if (this.resourceLoader == null) { throw new IllegalArgumentException( "'resourceLoader' application attribute must be present for SpringResourceLoader"); }//from ww w . j a v a 2 s. co m if (resourceLoaderPath == null) { throw new IllegalArgumentException( "'resourceLoaderPath' application attribute must be present for SpringResourceLoader"); } this.resourceLoaderPaths = StringUtils.commaDelimitedListToStringArray(resourceLoaderPath); for (int i = 0; i < this.resourceLoaderPaths.length; i++) { String path = this.resourceLoaderPaths[i]; if (!path.endsWith("/")) { this.resourceLoaderPaths[i] = path + "/"; } } if (logger.isInfoEnabled()) { logger.info("SpringResourceLoader for Velocity: using resource loader [" + this.resourceLoader + "] and resource loader paths " + Arrays.asList(this.resourceLoaderPaths)); } }
From source file:com.consol.citrus.mail.message.MailMessageConverter.java
@Override public void convertOutbound(MimeMailMessage mimeMailMessage, Message message, MailEndpointConfiguration endpointConfiguration) { MailMessage mailMessage = getMailMessage(message, endpointConfiguration); try {/*w w w .ja v a 2 s . c o m*/ mimeMailMessage.setFrom(mailMessage.getFrom()); mimeMailMessage.setTo(StringUtils.commaDelimitedListToStringArray(mailMessage.getTo())); if (StringUtils.hasText(mailMessage.getCc())) { mimeMailMessage.setCc(StringUtils.commaDelimitedListToStringArray(mailMessage.getCc())); } if (StringUtils.hasText(mailMessage.getBcc())) { mimeMailMessage.setBcc(StringUtils.commaDelimitedListToStringArray(mailMessage.getBcc())); } mimeMailMessage.setReplyTo( mailMessage.getReplyTo() != null ? mailMessage.getReplyTo() : mailMessage.getFrom()); mimeMailMessage.setSentDate(new Date()); mimeMailMessage.setSubject(mailMessage.getSubject()); mimeMailMessage.setText(mailMessage.getBody().getContent()); if (mailMessage.getBody().hasAttachments()) { for (AttachmentPart attachmentPart : mailMessage.getBody().getAttachments().getAttachments()) { mimeMailMessage.getMimeMessageHelper().addAttachment(attachmentPart.getFileName(), new ByteArrayResource(attachmentPart.getContent() .getBytes(Charset.forName(attachmentPart.getCharsetName()))), attachmentPart.getContentType()); } } } catch (MessagingException e) { throw new CitrusRuntimeException("Failed to create mail mime message", e); } }
From source file:org.jasig.schedassist.web.security.CalendarAccountUserDetailsServiceImpl.java
/** * @param administrators the administrators to set *//*from w w w.ja v a2 s . c om*/ public void setAdministratorListProperty(String propertyValue) { String[] admins = StringUtils.commaDelimitedListToStringArray(propertyValue); this.administrators = Arrays.asList(admins); }
From source file:fr.xebia.springframework.security.core.userdetails.memory.ExtendedUserMapBuilder.java
/** * Build an {@link fr.xebia.springframework.security.core.userdetails.ExtendedUser} from user attributes. * Protected for test purpose.//from w w w .j a v a 2s . c om * @param userAttributes a list. * @return the build {@link fr.xebia.springframework.security.core.userdetails.ExtendedUser}. */ protected static ExtendedUser buildExtendedUser(String userAttributes) { if (userAttributes == null) { return null; } String[] userAttributesStringArray = StringUtils.delimitedListToStringArray(userAttributes, "="); if (userAttributesStringArray.length != 2) { return null; // we need a username and some attributes. } String username = userAttributesStringArray[0].trim(); Pattern pattern = Pattern.compile("(enabled|disabled){1}$"); Matcher matcher = pattern.matcher(userAttributesStringArray[1].trim()); // Check activated attribute boolean activated = true; if (matcher.find()) { activated = ENABLED.equals(matcher.group()); } // Check authorized IP addresses String allowedIpAddresses = ""; pattern = Pattern.compile("@\\(.*\\)"); matcher = pattern.matcher(userAttributesStringArray[1]); if (matcher.find()) { allowedIpAddresses = StringUtils.deleteAny(matcher.group(), "@() "); } // Get user password and roles : pattern = Pattern.compile("((,\\ *@\\(.*\\)){0,1}(\\ *,\\ *(enabled|disabled)\\ *){0,1})$"); String[] remainingAttributes = pattern.split(userAttributesStringArray[1]); if (remainingAttributes.length != 1) { return null; // password and role(s) must have been defined. } String[] attributes = StringUtils.commaDelimitedListToStringArray(remainingAttributes[0]); if (attributes.length < 2) { return null; // we need at least one password and one role. } String password = attributes[0].trim(); List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(); for (int i = 1; i < attributes.length; i++) { authorities.add(new GrantedAuthorityImpl(attributes[i].trim())); } ExtendedUser extendedUser = new ExtendedUser(username, password, activated, true, true, true, authorities); extendedUser.setAllowedRemoteAddresses(allowedIpAddresses); return extendedUser; }
From source file:your.microservice.core.util.YourServletUriComponentsBuilder.java
/** * Prepare a builder by copying the scheme, host, port, path, and * query string of an HttpServletRequest. * @param request to build path from// w w w . j a va 2s . co m * @return a URI component builder */ public static YourServletUriComponentsBuilder fromRequest(HttpServletRequest request) { String scheme = request.getScheme(); String host = request.getServerName(); int port = request.getServerPort(); String hostHeader = request.getHeader("X-Forwarded-Host"); if (StringUtils.hasText(hostHeader)) { String[] hosts = StringUtils.commaDelimitedListToStringArray(hostHeader); String hostToUse = hosts[0]; if (hostToUse.contains(":")) { String[] hostAndPort = StringUtils.split(hostToUse, ":"); host = hostAndPort[0]; port = Integer.parseInt(hostAndPort[1]); } else { host = hostToUse; port = -1; } } String portHeader = request.getHeader("X-Forwarded-Port"); if (StringUtils.hasText(portHeader)) { port = Integer.parseInt(portHeader); } String protocolHeader = request.getHeader("X-Forwarded-Proto"); if (StringUtils.hasText(protocolHeader)) { scheme = protocolHeader; } YourServletUriComponentsBuilder builder = new YourServletUriComponentsBuilder(); builder.scheme(scheme); builder.host(host); if (scheme.equals("http") && port != 80 || scheme.equals("https") && port != 443) { builder.port(port); } builder.pathFromRequest(request); builder.query(request.getQueryString()); return builder; }
From source file:nivance.jpa.cassandra.prepare.core.CassandraClusterFactoryBean.java
@Override public void afterPropertiesSet() { Cluster.Builder builder = Cluster.builder(); builder.addContactPoints(StringUtils.commaDelimitedListToStringArray(contactPoints)).withPort(port); if (compressionType != null) { builder.withCompression(convertCompressionType(compressionType)); }/*from w w w .ja v a 2 s. com*/ if (localPoolingOptions != null || remotePoolingOptions != null) { builder.withPoolingOptions(getPoolingOptions()); } if (socketOptions != null) { builder.withSocketOptions(configSocketOptions(socketOptions)); } if (authProvider != null) { builder.withAuthProvider(authProvider); } if (loadBalancingPolicy != null) { builder.withLoadBalancingPolicy(loadBalancingPolicy); } if (reconnectionPolicy != null) { builder.withReconnectionPolicy(reconnectionPolicy); } if (retryPolicy != null) { builder.withRetryPolicy(retryPolicy); } if (!metricsEnabled) { builder.withoutMetrics(); } Cluster cluster = null; try { cluster = builder.build(); } catch (RuntimeException ex) { RuntimeException resolved = translateExceptionIfPossible(ex); throw resolved == null ? ex : resolved; } // initialize property this.cluster = cluster; cluster.connect(); }