use of org.springframework.shell.standard.ShellOption in project cas by apereo.
the class ExportPropertiesCommand method exportProperties.
/**
* Export properties.
*
* @param dir the directory for the configuration export
* @throws Exception the exception
*/
@ShellMethod(key = "export-props", value = "Export CAS properties and settings from configuration metadata.")
public void exportProperties(@ShellOption(value = { "dir", "--dir" }, help = "Path to a directory where reference configuration files would be exported.", defaultValue = "./etc/cas/config") final String dir) throws Exception {
val allProps = CasConfigurationMetadataCatalog.query(ConfigurationMetadataCatalogQuery.builder().queryType(ConfigurationMetadataCatalogQuery.QueryTypes.ALL).build());
try (val writer = Files.newBufferedWriter(new File(dir, "all-properties.ref").toPath(), Charset.defaultCharset())) {
allProps.properties().forEach(Unchecked.consumer(prop -> writeProperty(writer, prop)));
writer.flush();
}
val casProps = CasConfigurationMetadataCatalog.query(ConfigurationMetadataCatalogQuery.builder().queryType(ConfigurationMetadataCatalogQuery.QueryTypes.CAS).build());
try (val writer = Files.newBufferedWriter(new File(dir, "cas-properties.ref").toPath(), Charset.defaultCharset())) {
casProps.properties().forEach(Unchecked.consumer(prop -> writeProperty(writer, prop)));
writer.flush();
}
val thirdPartyProperties = CasConfigurationMetadataCatalog.query(ConfigurationMetadataCatalogQuery.builder().queryType(ConfigurationMetadataCatalogQuery.QueryTypes.THIRD_PARTY).build());
try (val writer = Files.newBufferedWriter(new File(dir, "thirdparty-properties.ref").toPath(), Charset.defaultCharset())) {
thirdPartyProperties.properties().forEach(Unchecked.consumer(prop -> writeProperty(writer, prop)));
writer.flush();
}
LOGGER.info("Exported configuration properties to [{}]", new File(dir).getAbsolutePath());
}
Aggregations