Search in sources :

Example 1 with ConfigurationMetadataRepository

use of org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository in project cas by apereo.

the class CasConfigurationMetadataCatalog method collectReferenceProperty.

private static CasReferenceProperty collectReferenceProperty(final ConfigurationMetadataProperty property, final ConfigurationMetadataRepository repository) {
    if (repository.getAllGroups().containsKey(property.getId())) {
        return null;
    }
    val builder = CasReferenceProperty.builder();
    builder.owner(determinePropertySourceType(property));
    property.getHints().getValueHints().forEach(Unchecked.consumer(hint -> {
        val description = hint.getDescription();
        if (StringUtils.isNotBlank(description)) {
            if (description.equals(RequiredProperty.class.getName())) {
                builder.required(true);
            }
            if (description.equals(RequiresModule.class.getName())) {
                val results = MAPPER.readValue(hint.getValue().toString(), Map.class);
                builder.module(results.get("module").toString());
            }
            if (description.equals(PropertyOwner.class.getName())) {
                val results = MAPPER.readValue(hint.getValue().toString(), Map.class);
                builder.owner(results.get("owner").toString());
            }
            if (description.equals(DurationCapable.class.getName())) {
                builder.duration(true);
            }
            if (description.equals(ExpressionLanguageCapable.class.getName())) {
                builder.expressionLanguage(true);
            }
        }
    }));
    builder.type(property.getType());
    val description = StringUtils.defaultString(StringUtils.defaultIfBlank(property.getDescription(), property.getShortDescription()));
    builder.description(description);
    builder.shortDescription(property.getShortDescription());
    builder.name(property.getId());
    builder.defaultValue(ObjectUtils.defaultIfNull(property.getDefaultValue(), StringUtils.EMPTY));
    if (property.isDeprecated()) {
        val deprecation = property.getDeprecation();
        builder.deprecationLevel(deprecation.getLevel().toString());
        if (deprecation.getShortReason() != null) {
            builder.deprecationReason(deprecation.getShortReason());
        }
        if (deprecation.getReplacement() != null) {
            builder.deprecationReplacement(deprecation.getReplacement());
        }
    }
    return builder.build();
}
Also used : lombok.val(lombok.val) RequiresModule(org.apereo.cas.configuration.support.RequiresModule) SneakyThrows(lombok.SneakyThrows) RequiredArgsConstructor(lombok.RequiredArgsConstructor) DurationCapable(org.apereo.cas.configuration.support.DurationCapable) StringUtils(org.apache.commons.lang3.StringUtils) TreeSet(java.util.TreeSet) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Map(java.util.Map) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) ConfigurationMetadataRepository(org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository) ValueHint(org.springframework.boot.configurationmetadata.ValueHint) Unchecked(org.jooq.lambda.Unchecked) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) lombok.val(lombok.val) RequiredProperty(org.apereo.cas.configuration.support.RequiredProperty) ConfigurationMetadataProperty(org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty) Collectors(java.util.stream.Collectors) File(java.io.File) Objects(java.util.Objects) ExpressionLanguageCapable(org.apereo.cas.configuration.support.ExpressionLanguageCapable) ReflectionUtils(org.springframework.util.ReflectionUtils) JacksonObjectMapperFactory(org.apereo.cas.util.serialization.JacksonObjectMapperFactory) PropertyOwner(org.apereo.cas.configuration.support.PropertyOwner) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) SerializationFeature(com.fasterxml.jackson.databind.SerializationFeature) Comparator(java.util.Comparator) Map(java.util.Map)

Example 2 with ConfigurationMetadataRepository

use of org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository in project microservices by pwillhan.

the class MetaDataTests method writeMetadataInfo.

@Test
public void writeMetadataInfo() throws Exception {
    InputStream inputStream = new FileInputStream("target/classes/META-INF/spring-configuration-metadata.json");
    ConfigurationMetadataRepository repository = ConfigurationMetadataRepositoryJsonBuilder.create(UTF_8).withJsonResource(inputStream).build();
    for (Map.Entry<String, ConfigurationMetadataProperty> entry : repository.getAllProperties().entrySet()) {
        System.out.println(entry.getKey() + " = " + entry.getValue().getShortDescription());
    }
}
Also used : ConfigurationMetadataProperty(org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ConfigurationMetadataRepository(org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository) Map(java.util.Map) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 3 with ConfigurationMetadataRepository

use of org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository in project spring-boot by spring-projects.

the class PropertiesMigrationListener method onApplicationPreparedEvent.

private void onApplicationPreparedEvent(ApplicationPreparedEvent event) {
    ConfigurationMetadataRepository repository = loadRepository();
    PropertiesMigrationReporter reporter = new PropertiesMigrationReporter(repository, event.getApplicationContext().getEnvironment());
    this.report = reporter.getReport();
}
Also used : ConfigurationMetadataRepository(org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository)

Aggregations

ConfigurationMetadataRepository (org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository)3 Map (java.util.Map)2 ConfigurationMetadataProperty (org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty)2 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 Comparator (java.util.Comparator)1 Objects (java.util.Objects)1 TreeSet (java.util.TreeSet)1 Collectors (java.util.stream.Collectors)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 SneakyThrows (lombok.SneakyThrows)1 lombok.val (lombok.val)1 ObjectUtils (org.apache.commons.lang3.ObjectUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 DurationCapable (org.apereo.cas.configuration.support.DurationCapable)1