* @throws ServletException
* @throws IOException
*/
public void enabledDisabledLogs ( HttpServletRequest request, HttpServletResponse response ) throws JSONException, IOException {
JSONObject jsonResponse = new JSONObject();
try {
//Getting the names of the selected logs
String[] selectedLogs = null;
String selectedLogsParam = getURIParams().get( "selection" );
if ( selectedLogsParam != null ) {
selectedLogs = selectedLogsParam.split( "," );
}
if ( selectedLogs != null ) {
//Getting our current logs
List<LogMapperRow> currentLogs = LogMapper.getInstance().getLogList();
for ( LogMapperRow logMapperRow : currentLogs ) {
for ( String selectedLog : selectedLogs ) {
//Compare to see if this log was selected in the UI by the client
if ( logMapperRow.getLog_name().equals( selectedLog ) ) {
if ( logMapperRow.getEnabled() ) {
logMapperRow.setEnabled( false );
} else {
logMapperRow.setEnabled( true );
}
}
}
}
//Update the modified logs
LogMapper.getInstance().updateLogsList();
}
//And finally preparing the log list json to send it to the client with the modified values
jsonResponse = prepareAndResponseLogList( response );
} catch ( Exception e ) {
jsonResponse.put( "response", "error" );
jsonResponse.put( "message", "Error updating logs." );
Logger.error( LogConsoleAjaxAction.class, "Error updating logs.", e );
}
//Sending the json response
prepareResponse( jsonResponse.toString(), CONTENT_JSON, response );
}