@ ShellMethod ( key = "add-properties" , value = "Add properties associated with a CAS group/module to a Properties/Yaml configuration file." ) public static void add ( @ ShellOption ( value = { "file" } , help = "Path to the CAS configuration file" , defaultValue = "/etc/cas/config/cas.properties" ) final String file , @ ShellOption ( value = { "group" } , help = "Group/module whose associated settings should be added to the CAS configuration file" ) final String group ) throws Exception { if ( StringUtils . isBlank ( file ) ) { LOGGER . warn ( "Configuration file must be specified" ) ; return ; } val filePath = new File ( file ) ; if ( filePath . exists ( ) && ( filePath . isDirectory ( ) || ! filePath . canRead ( ) || ! filePath . canWrite ( ) ) ) { LOGGER . warn ( "Configuration file [{}] is not readable/writable or is not a path to a file" , filePath . getCanonicalPath ( ) ) ; return ; } val results = findProperties ( group ) ; LOGGER . info ( "Located [{}] properties matching [{}]" , results . size ( ) , group ) ; switch ( FilenameUtils . getExtension ( filePath . getName ( ) ) . toLowerCase ( ) ) { case "properties" : createConfigurationFileIfNeeded ( filePath ) ; val props = loadPropertiesFromConfigurationFile ( filePath ) ; writeConfigurationPropertiesToFile ( filePath , results , props ) ; break ; case "yml" : createConfigurationFileIfNeeded ( filePath ) ; val yamlProps = CasCoreConfigurationUtils . loadYamlProperties ( new FileSystemResource ( filePath ) ) ; writeYamlConfigurationPropertiesToFile ( filePath , results , yamlProps ) ; break ; default : LOGGER . warn ( "Configuration file format [{}] is not recognized" , filePath . getCanonicalPath ( ) ) ; } }
Add properties to configuration .