private void applyChanges ( PrintWriter out , Reconfigurable reconf , HttpServletRequest req ) throws IOException , ReconfigurationException { Configuration oldConf = reconf . getConf ( ) ; Configuration newConf = new Configuration ( ) ; if ( reconf instanceof ReconfigurableBase ) ( ( ReconfigurableBase ) reconf ) . preProcessConfiguration ( newConf ) ; Enumeration < String > params = getParams ( req ) ; synchronized ( oldConf ) { while ( params . hasMoreElements ( ) ) { String rawParam = params . nextElement ( ) ; String param = StringEscapeUtils . unescapeHtml ( rawParam ) ; String value = StringEscapeUtils . unescapeHtml ( req . getParameter ( rawParam ) ) ; if ( reconf instanceof ReconfigurableBase ) param = ( ( ReconfigurableBase ) reconf ) . preProcessKey ( param ) ; if ( value != null ) { if ( value . equals ( newConf . getRaw ( param ) ) || value . equals ( "default" ) || value . equals ( "null" ) || value . equals ( "" ) ) { if ( ( value . equals ( "default" ) || value . equals ( "null" ) || value . equals ( "" ) ) && oldConf . getRaw ( param ) != null ) { out . println ( "<p>Changed \"" + StringEscapeUtils . escapeHtml ( param ) + "\" from \"" + StringEscapeUtils . escapeHtml ( oldConf . getRaw ( param ) ) + "\" to default</p>" ) ; reconf . reconfigureProperty ( param , null ) ; } else if ( ! value . equals ( "default" ) && ! value . equals ( "null" ) && ! value . equals ( "" ) && ( oldConf . getRaw ( param ) == null || ! oldConf . getRaw ( param ) . equals ( value ) ) ) { // change from default or value to different value if ( oldConf . getRaw ( param ) == null ) { out . println ( "<p>Changed \"" + StringEscapeUtils . escapeHtml ( param ) + "\" from default to \"" + StringEscapeUtils . escapeHtml ( value ) + "\"</p>" ) ; } else { out . println ( "<p>Changed \"" + StringEscapeUtils . escapeHtml ( param ) + "\" from \"" + StringEscapeUtils . escapeHtml ( oldConf . getRaw ( param ) ) + "\" to \"" + StringEscapeUtils . escapeHtml ( value ) + "\"</p>" ) ; } reconf . reconfigureProperty ( param , value ) ; } else { LOG . info ( "property " + param + " unchanged" ) ; } } else { // parameter value != newConf value out . println ( "<p>\"" + StringEscapeUtils . escapeHtml ( param ) + "\" not changed because value has changed from \"" + StringEscapeUtils . escapeHtml ( value ) + "\" to \"" + StringEscapeUtils . escapeHtml ( newConf . getRaw ( param ) ) + "\" since approval</p>" ) ; } } } } }
Apply configuration changes after admin has approved them .