use of org.apereo.cas.metadata.CasReferenceProperty in project cas by apereo.
the class CasDocumentationApplication method main.
public static void main(final String[] args) throws Exception {
var options = new Options();
var dt = new Option("d", "data", true, "Data directory");
dt.setRequired(true);
options.addOption(dt);
var ver = new Option("v", "version", true, "Project version");
ver.setRequired(true);
options.addOption(ver);
var root = new Option("r", "root", true, "Project root directory");
root.setRequired(true);
options.addOption(root);
var ft = new Option("f", "filter", true, "Property filter pattern");
ft.setRequired(false);
options.addOption(ft);
var act = new Option("a", "actuators", true, "Generate data for actuator endpoints");
act.setRequired(false);
options.addOption(act);
var tp = new Option("tp", "thirdparty", true, "Generate data for third party");
tp.setRequired(false);
options.addOption(tp);
var sp = new Option("sp", "serviceproperties", true, "Generate data for registered services properties");
sp.setRequired(false);
options.addOption(sp);
var feats = new Option("ft", "features", true, "Generate data for feature toggles and descriptors");
feats.setRequired(false);
options.addOption(feats);
new HelpFormatter().printHelp("CAS Documentation", options);
var cmd = new DefaultParser().parse(options, args);
var dataDirectory = cmd.getOptionValue("data");
var projectVersion = cmd.getOptionValue("version");
var projectRootDirectory = cmd.getOptionValue("root");
var propertyFilter = cmd.getOptionValue("filter", ".+");
var results = CasConfigurationMetadataCatalog.query(ConfigurationMetadataCatalogQuery.builder().queryType(ConfigurationMetadataCatalogQuery.QueryTypes.CAS).queryFilter(property -> RegexUtils.find(propertyFilter, property.getName())).build());
var groups = new HashMap<String, Set<CasReferenceProperty>>();
results.properties().stream().filter(property -> StringUtils.isNotBlank(property.getModule())).peek(property -> {
var desc = cleanDescription(property);
property.setDescription(desc);
}).forEach(property -> {
if (groups.containsKey(property.getModule())) {
groups.get(property.getModule()).add(property);
} else {
var values = new TreeSet<CasReferenceProperty>();
values.add(property);
groups.put(property.getModule(), values);
}
});
var dataPath = new File(dataDirectory, projectVersion);
if (dataPath.exists()) {
FileUtils.deleteQuietly(dataPath);
}
dataPath.mkdirs();
groups.forEach((key, value) -> {
var destination = new File(dataPath, key);
destination.mkdirs();
var configFile = new File(destination, "config.yml");
CasConfigurationMetadataCatalog.export(configFile, value);
});
var thirdparty = cmd.getOptionValue("thirdparty", "true");
if (StringUtils.equalsIgnoreCase("true", thirdparty)) {
exportThirdPartyConfiguration(dataPath, propertyFilter);
}
var registeredServicesProps = cmd.getOptionValue("serviceproperties", "true");
if (StringUtils.equalsIgnoreCase("true", registeredServicesProps)) {
exportRegisteredServiceProperties(dataPath);
}
exportTemplateViews(projectRootDirectory, dataPath);
exportThemeProperties(projectRootDirectory, dataPath);
var actuators = cmd.getOptionValue("actuators", "true");
if (StringUtils.equalsIgnoreCase("true", actuators)) {
exportActuatorEndpoints(dataPath);
}
var features = cmd.getOptionValue("features", "true");
if (StringUtils.equalsIgnoreCase("true", features)) {
exportFeatureToggles(dataPath);
}
}
Aggregations