use of com.loohp.interactivechat.libs.org.apache.commons.lang3.ArrayUtils in project kylo by Teradata.
the class JaasAuthConfig method jaasConfiguration.
@Bean(name = "jaasConfiguration")
public javax.security.auth.login.Configuration jaasConfiguration(Optional<List<LoginConfiguration>> loginModuleEntries) {
// Generally the entries will be null only in situations like unit/integration tests.
if (loginModuleEntries.isPresent()) {
List<LoginConfiguration> sorted = new ArrayList<>(loginModuleEntries.get());
sorted.sort(new AnnotationAwareOrderComparator());
Map<String, AppConfigurationEntry[]> merged = sorted.stream().map(c -> c.getAllApplicationEntries().entrySet()).flatMap(s -> s.stream()).collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue(), ArrayUtils::addAll));
return new InMemoryConfiguration(merged);
} else {
return new InMemoryConfiguration(Collections.emptyMap());
}
}
use of com.loohp.interactivechat.libs.org.apache.commons.lang3.ArrayUtils in project so by onap.
the class FluentGenerator method createInterfaceMethods.
protected List<MethodSpec> createInterfaceMethods(ObjectType oType, List<ParameterSpec> typeParams) {
List<MethodSpec> methods = new ArrayList<>();
CodeBlock.Builder uriTemplateCodeBlock = CodeBlock.builder();
if (!oType.getType().equals("top level")) {
uriTemplateCodeBlock.add("return this.parentObj.uriTemplate() + Info.partialUri");
} else {
uriTemplateCodeBlock.add("return Info.partialUri");
}
methods.add(MethodSpec.methodBuilder("uriTemplate").returns(String.class).addModifiers(Modifier.PUBLIC).addStatement(uriTemplateCodeBlock.build()).addAnnotation(Override.class).build());
ClassName arrayUtils = ClassName.get(ArrayUtils.class);
CodeBlock.Builder valuesReturn = CodeBlock.builder();
if (oType.getType().equals("top level")) {
valuesReturn.add("return new Object[0]");
} else {
if (!typeParams.isEmpty()) {
valuesReturn.add("return $T.addAll(this.parentObj.values(), $L)", arrayUtils, String.join(", ", typeParams.stream().map(item -> "this." + item.name).collect(Collectors.toList())));
} else {
valuesReturn.add("return this.parentObj.values()");
}
}
methods.add(MethodSpec.methodBuilder("values").returns(Object[].class).addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement(valuesReturn.build()).build());
if (!oType.getType().equals("top level")) {
ClassName returnType = null;
CodeBlock.Builder block = CodeBlock.builder();
if (oType.getType().equals("singular")) {
Pair<String, String> path = splitClasspath(this.singularClass);
returnType = ClassName.get(path.getLeft(), path.getRight());
block.add("return new $T(this.parentObj.uriTemplate(), Info.partialUri, Info.name, false)", returnType);
} else if (oType.getType().equals("plural")) {
Pair<String, String> path = splitClasspath(this.pluralClass);
returnType = ClassName.get(path.getLeft(), path.getRight());
block.add("return new $T(Info.name, this.parentObj.uriTemplate(), Info.partialUri)", returnType);
}
methods.add(MethodSpec.methodBuilder("build").returns(returnType).addModifiers(Modifier.PUBLIC).addAnnotation(Override.class).addStatement(block.build()).build());
}
return methods;
}
use of com.loohp.interactivechat.libs.org.apache.commons.lang3.ArrayUtils in project sduoj-server by SDUOJ.
the class PermissionInitListener method started.
@Override
public void started(ConfigurableApplicationContext context) {
ConfigurableEnvironment environment = context.getEnvironment();
String applicationPrefixUrl = Optional.ofNullable(environment.getProperty("server.servlet.context-path")).filter(StringUtils::isNotBlank).orElse("");
List<PermissionDTO> permissionDTOList = Lists.newArrayList();
Map<String, Object> beanMap = context.getBeansWithAnnotation(Controller.class);
for (Entry<String, Object> objectEntry : beanMap.entrySet()) {
if (ESCAPE_CONTROLLER.contains(objectEntry.getKey())) {
continue;
}
Object value = objectEntry.getValue();
Class<?> valueClass = value.getClass();
String classMappingUrl = Optional.ofNullable(valueClass.getAnnotation(RequestMapping.class)).map(RequestMapping::value).filter(ArrayUtils::isNotEmpty).map(values -> values[0]).orElse("");
Method[] methods = valueClass.getMethods();
for (Method method : methods) {
for (Class<? extends Annotation> mappingClass : MAPPING_CLASSES) {
Annotation mappingAnnotation = method.getAnnotation(mappingClass);
if (mappingAnnotation != null) {
try {
Method valueMethod = mappingClass.getDeclaredMethod("value");
Method nameMethod = mappingClass.getDeclaredMethod("name");
String methodMappingUrl = Optional.ofNullable((String[]) valueMethod.invoke(mappingAnnotation)).filter(ArrayUtils::isNotEmpty).map(values -> values[0]).orElse("");
String url = String.format("/%s/%s/%s", applicationPrefixUrl, classMappingUrl, methodMappingUrl).replaceAll("[/]+", "/");
String name = (String) nameMethod.invoke(mappingAnnotation);
permissionDTOList.add(PermissionDTO.builder().name(name).url(url).build());
log.info("syncUrl {} {}", name, url);
} catch (Throwable t) {
log.error("", t);
}
}
}
}
}
// 远程调用 auth 微服务同步过去
if (!permissionDTOList.isEmpty()) {
try {
loadBalancerClient = (LoadBalancerClient) context.getBean("loadBalancerClient");
} catch (Throwable t) {
log.error("", t);
}
syncUrl(permissionDTOList, 0);
}
}
Aggregations