New api
This commit is contained in:
@ -6,13 +6,16 @@ import java.util.EnumMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.msgpack.jackson.dataformat.MessagePackFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -429,8 +432,9 @@ public class QueryRestConfig { // extends WebMvcConfigurerAdapter {
|
||||
|
||||
final String newDefaultProtocol = "https";
|
||||
final String newDefaultHost = "data-api.psi.ch";
|
||||
|
||||
LOGGER.warn("\nSet back to 443!\n#####");
|
||||
|
||||
|
||||
LOGGER.warn("\nSet back to 443!\n#####");
|
||||
final int newDefaultPort = 8080;
|
||||
// this should be overwritten
|
||||
final String newDefaultPath = "";
|
||||
@ -450,11 +454,25 @@ public class QueryRestConfig { // extends WebMvcConfigurerAdapter {
|
||||
@Bean(name = BEAN_NAME_QUERY_SERVER_BACKENDS)
|
||||
@Lazy
|
||||
public Map<Backend, String> queryServerBackends() {
|
||||
final BiFunction<String, String, BackendType> typeCreator =
|
||||
(name, queryServer) -> new DomainBackendType(name, queryServer);
|
||||
final BiFunction<String, Pair<String, String>, BackendType> typeCreator =
|
||||
(name, serverAddresses) -> new DomainBackendType(
|
||||
name,
|
||||
serverAddresses.getLeft(),
|
||||
serverAddresses.getRight());
|
||||
@SuppressWarnings("unchecked")
|
||||
final List<String> queryServerAddresses =
|
||||
context.getBean(QueryRestConfig.BEAN_NAME_QUERY_SERVER_ADDRESSES, List.class);
|
||||
return RestHelper.getBackends(context, queryServerAddresses, typeCreator);
|
||||
return RestHelper.getBackends(
|
||||
context,
|
||||
queryServerAddresses.stream()
|
||||
.map(queryServer -> Pair.of(queryServer, null)),
|
||||
serverAddresses -> serverAddresses.getLeft(),
|
||||
DomainConfig.PATH_BACKENDS_BY_ID,
|
||||
typeCreator)
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
Entry::getKey,
|
||||
entry -> entry.getValue().getLeft()));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user