Java Code Examples for org.springframework.util.StringUtils#collectionToCommaDelimitedString()

The following examples show how to use org.springframework.util.StringUtils#collectionToCommaDelimitedString() . These examples are extracted from open source projects. 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
@Override
public Mono<Void> execute(URI url, HttpHeaders requestHeaders, WebSocketHandler handler) {
	String protocols = StringUtils.collectionToCommaDelimitedString(handler.getSubProtocols());
	return getHttpClient()
			.headers(nettyHeaders -> setNettyHeaders(requestHeaders, nettyHeaders))
			.websocket(protocols, getMaxFramePayloadLength())
			.uri(url.toString())
			.handle((inbound, outbound) -> {
				HttpHeaders responseHeaders = toHttpHeaders(inbound);
				String protocol = responseHeaders.getFirst("Sec-WebSocket-Protocol");
				HandshakeInfo info = new HandshakeInfo(url, responseHeaders, Mono.empty(), protocol);
				NettyDataBufferFactory factory = new NettyDataBufferFactory(outbound.alloc());
				WebSocketSession session = new ReactorNettyWebSocketSession(
						inbound, outbound, info, factory, getMaxFramePayloadLength());
				if (logger.isDebugEnabled()) {
					logger.debug("Started session '" + session.getId() + "' for " + url);
				}
				return handler.handle(session).checkpoint(url + " [ReactorNettyWebSocketClient]");
			})
			.doOnRequest(n -> {
				if (logger.isDebugEnabled()) {
					logger.debug("Connecting to " + url);
				}
			})
			.next();
}
 
Example 2
private String[] getActiveProfile(ConfigurableEnvironment appEnvironment) {
    List<String> serviceProfiles = new ArrayList<>();

    for (String profile : appEnvironment.getActiveProfiles()) {
        if (validLocalProfiles.contains(profile)) {
            serviceProfiles.add(profile);
        }
    }

    if (serviceProfiles.size() > 1) {
        throw new IllegalStateException("Only one active Spring profile may be set among the following: " +
                validLocalProfiles.toString() + ". " +
                "These profiles are active: [" +
                StringUtils.collectionToCommaDelimitedString(serviceProfiles) + "]");
    }

    if (serviceProfiles.size() > 0) {
        return createProfileNames(serviceProfiles.get(0), "local");
    }

    return null;
}
 
Example 3
@Override
public Class<?> getType(String name) throws NoSuchBeanDefinitionException {
	String beanName = BeanFactoryUtils.transformedBeanName(name);

	Object bean = this.beans.get(beanName);
	if (bean == null) {
		throw new NoSuchBeanDefinitionException(beanName,
				"Defined beans are [" + StringUtils.collectionToCommaDelimitedString(this.beans.keySet()) + "]");
	}

	if (bean instanceof FactoryBean && !BeanFactoryUtils.isFactoryDereference(name)) {
		// If it's a FactoryBean, we want to look at what it creates, not the factory class.
		return ((FactoryBean<?>) bean).getObjectType();
	}
	return bean.getClass();
}
 
Example 4
/**
 * This implementation first checks to see if the name specified is the special
 * {@linkplain #setNonOptionArgsPropertyName(String) "non-option arguments" property},
 * and if so delegates to the abstract {@link #getNonOptionArgs()} method. If so
 * and the collection of non-option arguments is empty, this method returns {@code
 * null}. If not empty, it returns a comma-separated String of all non-option
 * arguments. Otherwise delegates to and returns the result of the abstract {@link
 * #getOptionValues(String)} method.
 */
@Override
public final String getProperty(String name) {
	if (this.nonOptionArgsPropertyName.equals(name)) {
		Collection<String> nonOptionArguments = this.getNonOptionArgs();
		if (nonOptionArguments.isEmpty()) {
			return null;
		}
		else {
			return StringUtils.collectionToCommaDelimitedString(nonOptionArguments);
		}
	}
	Collection<String> optionValues = this.getOptionValues(name);
	if (optionValues == null) {
		return null;
	}
	else {
		return StringUtils.collectionToCommaDelimitedString(optionValues);
	}
}
 
Example 5
private String toCommaSeperatedList(Properties tags) {
    if (tags.isEmpty()) {
        return "";
    }
    else {
        return StringUtils.collectionToCommaDelimitedString(
                tags.keySet().stream().map(k -> "\"" + k + "\"").collect(Collectors.toList()));
    }
}
 
Example 6
private String[] getCloudProfiles(Cloud cloud) {
    if (cloud == null) {
        return null;
    }

    List<String> profiles = new ArrayList<>();

    List<ServiceInfo> serviceInfos = cloud.getServiceInfos();

    LOGGER.info("Found serviceInfos: " + StringUtils.collectionToCommaDelimitedString(serviceInfos));

    for (ServiceInfo serviceInfo : serviceInfos) {
        if (serviceTypeToProfileName.containsKey(serviceInfo.getClass())) {
            profiles.add(serviceTypeToProfileName.get(serviceInfo.getClass()));
        }
    }

    if (profiles.size() > 1) {
        throw new IllegalStateException(
                "Only one service of the following types may be bound to this application: " +
                        serviceTypeToProfileName.values().toString() + ". " +
                        "These services are bound to the application: [" +
                        StringUtils.collectionToCommaDelimitedString(profiles) + "]");
    }

    if (profiles.size() > 0) {
        return createProfileNames(profiles.get(0), "cloud");
    }

    return null;
}
 
Example 7
private String toCommaDelimitedHostAndPortsString(List<InetSocketAddress> socketAddresses) {

		return StringUtils.collectionToCommaDelimitedString(nullSafeList(socketAddresses).stream()
			.filter(Objects::nonNull)
			.map(socketAddress -> String.format("%1$s:%2$d", socketAddress.getHostName(), socketAddress.getPort()))
			.collect(Collectors.toList()));
	}
 
Example 8
public String[] getCloudProfile(Cloud cloud) {
    if (cloud == null) {
        return null;
    }

    List<String> profiles = new ArrayList<>();

    List<ServiceInfo> serviceInfos = cloud.getServiceInfos();

    logger.info("Found serviceInfos: " + StringUtils.collectionToCommaDelimitedString(serviceInfos));

    for (ServiceInfo serviceInfo : serviceInfos) {
        if (serviceTypeToProfileName.containsKey(serviceInfo.getClass())) {
            profiles.add(serviceTypeToProfileName.get(serviceInfo.getClass()));
        }
    }

    if (profiles.size() > 1) {
        throw new IllegalStateException(
                "Only one service of the following types may be bound to this application: " +
                        serviceTypeToProfileName.values().toString() + ". " +
                        "These services are bound to the application: [" +
                        StringUtils.collectionToCommaDelimitedString(profiles) + "]");
    }

    if (profiles.size() > 0) {
        return createProfileNames(profiles.get(0), "cloud");
    }

    return null;
}
 
Example 9
Source Project: watchdog-spring-boot-starter   File: FieldUtil.java    License: MIT License 5 votes vote down vote up
public static String getAutoApproveScopes(ClientDetails clientDetails) {
    if (clientDetails.isAutoApprove("true")) {
        return "true"; // all scopes autoapproved
    }
    Set<String> scopes = new HashSet<String>();
    for (String scope : clientDetails.getScope()) {
        if (clientDetails.isAutoApprove(scope)) {
            scopes.add(scope);
        }
    }
    return StringUtils.collectionToCommaDelimitedString(scopes);
}
 
Example 10
@GetMapping("/edit/{id}")
public String edit(@PathVariable Integer id, Model model) {
    Topic topic = topicService.selectById(id);
    Assert.isTrue(topic.getUserId().equals(getUser().getId()), "谁给你的权限修改别人的话题的?");
    // 查询话题的标签
    List<Tag> tagList = tagService.selectByTopicId(id);
    // 将标签集合转成逗号隔开的字符串
    String tags = StringUtils.collectionToCommaDelimitedString(tagList.stream().map(Tag::getName).collect(Collectors
            .toList()));

    model.addAttribute("topic", topic);
    model.addAttribute("tags", tags);
    return render("topic/edit");
}
 
Example 11
/**
 * Create a new {@code NoUniqueBeanDefinitionException}.
 * @param type required type of the non-unique bean
 * @param beanNamesFound the names of all matching beans (as a Collection)
 * @since 5.1
 */
public NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound) {
	super(type, "expected single matching bean but found " + beanNamesFound.size() + ": " +
			StringUtils.collectionToCommaDelimitedString(beanNamesFound));
	this.numberOfBeansFound = beanNamesFound.size();
	this.beanNamesFound = beanNamesFound;
}
 
Example 12
Source Project: MaxKey   File: AppsOAuth20Details.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 
 */
public AppsOAuth20Details(Apps application, BaseClientDetails baseClientDetails) {
    super();
    this.id = application.getId();
    this.setName(application.getName());
    this.setLoginUrl(application.getLoginUrl());
    this.setCategory(application.getCategory());
    this.setProtocol(application.getProtocol());
    this.setIcon(application.getIcon());
    this.clientId = application.getId();

    this.setSortIndex(application.getSortIndex());
    this.setVendor(application.getVendor());
    this.setVendorUrl(application.getVendorUrl());

    this.clientSecret = baseClientDetails.getClientSecret();
    this.scope = baseClientDetails.getScope().toString();
    this.resourceIds = baseClientDetails.getResourceIds().toString();
    this.authorizedGrantTypes = baseClientDetails.getAuthorizedGrantTypes().toString();
    this.registeredRedirectUris = StringUtils
            .collectionToCommaDelimitedString(baseClientDetails.getRegisteredRedirectUri());
    this.authorities = baseClientDetails.getAuthorities().toString();
    this.accessTokenValiditySeconds = baseClientDetails.getAccessTokenValiditySeconds();
    this.refreshTokenValiditySeconds = baseClientDetails.getRefreshTokenValiditySeconds();
    this.approvalPrompt = baseClientDetails.isAutoApprove("all") + "";

    this.idTokenEncryptedAlgorithm = baseClientDetails.getIdTokenEncryptedAlgorithm();
    this.idTokenEncryptionMethod = baseClientDetails.getIdTokenEncryptionMethod();
    this.idTokenSigningAlgorithm = baseClientDetails.getIdTokenSigningAlgorithm();

    this.userInfoEncryptedAlgorithm = baseClientDetails.getUserInfoEncryptedAlgorithm();
    this.userInfoEncryptionMethod = baseClientDetails.getUserInfoEncryptionMethod();
    this.userInfoSigningAlgorithm = baseClientDetails.getUserInfoSigningAlgorithm();

    this.jwksUri = baseClientDetails.getJwksUri();

}
 
Example 13
@Override
public String toString() {
	return StringUtils.collectionToCommaDelimitedString(this.converters);
}
 
Example 14
Source Project: ecs-sync   File: SyncRecord.java    License: Apache License 2.0 4 votes vote down vote up
public static String selectErrors(String tableName) {
    return "select " + StringUtils.collectionToCommaDelimitedString(ALL_FIELDS)
            + " from " + tableName + " where status = '" + ObjectStatus.Error.getValue() + "'";
}
 
Example 15
@Override
public String toString() {
	return StringUtils.collectionToCommaDelimitedString(this.converters);
}
 
Example 16
@Override
public String toString() {
	return StringUtils.collectionToCommaDelimitedString(this.converters);
}
 
Example 17
/**
 * Method to check process lists.
 * 
 * @param username
 * @param hostname
 * @param authUsingPassword
 * @param authInfo
 * @return
 */
private Status checkProcessList(String username, String hostname,
		boolean authUsingPassword, String authInfo) {
	String processList = "";
	String message = null;
	try {
		processList = SSHUtils.getCommandOutput("jps", hostname, username,
				authInfo, authUsingPassword);
	} catch (Exception e) {
		message = e.getMessage();
		logger.error(message, e);
	}

	List<String> processes = null;
	if ((processList == null) || processList.isEmpty()) {
		processes = new ArrayList<String>();
	} else {
		processes = new ArrayList<String>(Arrays.asList(processList
				.split("\n")));
	}

	List<String> processLists = new ArrayList<String>();
	for (String process : processes) {
		if (!(process.contains("Jps") || process
				.contains(AgentDeployer.ANKUSH_SERVER_PROCSS_NAME))) {
			String[] processArray = process.split("\\ ");
			if (processArray.length == 2) {
				processLists.add(process.split("\\ ")[1]);
			}
		}
	}

	if (processLists.isEmpty()) {
		return new Status("JPS process list", OK);
	} else {
		message = StringUtils
				.collectionToCommaDelimitedString(processLists)
				+ " already running";
		return new Status("JPS process list", message, WARNING);
	}
}
 
Example 18
@Override
public String toString() {
	return StringUtils.collectionToCommaDelimitedString(this.converters);
}
 
Example 19
/**
 * Create a new {@code NoUniqueBeanDefinitionException}.
 * @param type required type of the non-unique bean
 * @param beanNamesFound the names of all matching beans (as a Collection)
 */
public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound) {
	this(type, beanNamesFound.size(), "expected single matching bean but found " + beanNamesFound.size() + ": " +
			StringUtils.collectionToCommaDelimitedString(beanNamesFound));
}
 
Example 20
/**
 * Create a new {@code NoUniqueBeanDefinitionException}.
 * @param type required type of the non-unique bean
 * @param beanNamesFound the names of all matching beans (as a Collection)
 */
public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound) {
	this(type, beanNamesFound.size(), "expected single matching bean but found " + beanNamesFound.size() + ": " +
			StringUtils.collectionToCommaDelimitedString(beanNamesFound));
}