Commit 4ce1b94c authored by Michael Ritter's avatar Michael Ritter
Browse files

Rename auto.audit.disable to auto.audit.enable

parent be92cc92
...@@ -190,10 +190,11 @@ public final class AuditConfigurationContext implements ServletContextListener { ...@@ -190,10 +190,11 @@ public final class AuditConfigurationContext implements ServletContextListener {
PauseBean pb = new PauseBean(); PauseBean pb = new PauseBean();
ctx.setAttribute(ATTRIBUTE_PAUSE, pb); ctx.setAttribute(ATTRIBUTE_PAUSE, pb);
q.setParameter("attr", SettingsConstants.PARAM_DISABLE_AUTO_AUDIT); q.setParameter("attr", SettingsConstants.PARAM_AUTO_AUDIT_ENABLE);
s = (SettingsParameter) q.getSingleResult(); s = (SettingsParameter) q.getSingleResult();
String startPaused = s.getValue(); // Invert the boolean because the PB checks if we're paused, not enabled
pb.setPaused(Boolean.valueOf(startPaused)); String enableAudits = s.getValue();
pb.setPaused(!Boolean.valueOf(enableAudits));
q.setParameter("attr", SettingsConstants.PARAM_THROTTLE_MAXAUDIT); q.setParameter("attr", SettingsConstants.PARAM_THROTTLE_MAXAUDIT);
s = (SettingsParameter) q.getSingleResult(); s = (SettingsParameter) q.getSingleResult();
......
...@@ -14,7 +14,7 @@ public class SettingsConstants { ...@@ -14,7 +14,7 @@ public class SettingsConstants {
public static final String PARAM_IMS_PORT = "ims.port"; public static final String PARAM_IMS_PORT = "ims.port";
public static final String PARAM_IMS_TOKEN_CLASS = "ims.tokenclass"; public static final String PARAM_IMS_TOKEN_CLASS = "ims.tokenclass";
public static final String PARAM_IMS_SSL = "ims.ssl"; public static final String PARAM_IMS_SSL = "ims.ssl";
public static final String PARAM_DISABLE_AUTO_AUDIT = "auto.audit.disable"; public static final String PARAM_AUTO_AUDIT_ENABLE = "auto.audit.enable";
public static final String PARAM_THROTTLE_MAXAUDIT = "throttle.maxaudit"; public static final String PARAM_THROTTLE_MAXAUDIT = "throttle.maxaudit";
public static final String PARAM_TIME = "throttle.wait"; public static final String PARAM_TIME = "throttle.wait";
public static final String PARAM_BPS = "throttle.bps"; public static final String PARAM_BPS = "throttle.bps";
......
...@@ -65,8 +65,7 @@ public class SettingsMigrationContextListener implements ServletContextListener{ ...@@ -65,8 +65,7 @@ public class SettingsMigrationContextListener implements ServletContextListener{
} }
if (!newTable) { if (!newTable) {
//LOG.info("SQL patch to 1.7+ has not been installed, table 'settings' does no exist, shutting down!"); throw new IllegalStateException("SQL patch to 1.7+ has not been installed, table 'settings' does not exist");
throw new IllegalStateException("SQL patch to 1.7+ has not been installed, table 'settings' does no exist");
} }
// Find out if there are any elements in the table // Find out if there are any elements in the table
......
...@@ -20,7 +20,12 @@ import java.util.Set; ...@@ -20,7 +20,12 @@ import java.util.Set;
*/ */
public class SettingsUtil { public class SettingsUtil {
// Get an item by its attribute name /**
* Retrieve a Setting based off it's attribute name
*
* @param attr the attribute to query on
* @return the Setting associated with the attribute
*/
public static SettingsParameter getItemByAttr( String attr ) { public static SettingsParameter getItemByAttr( String attr ) {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("SettingsParameter.getAttr"); Query q = em.createNamedQuery("SettingsParameter.getAttr");
...@@ -35,7 +40,11 @@ public class SettingsUtil { ...@@ -35,7 +40,11 @@ public class SettingsUtil {
return null; return null;
} }
// Return a list of all custom settings /**
* Get a list of all custom settings
*
* @return custom settings
*/
public static List<SettingsParameter> getCustomSettings() { public static List<SettingsParameter> getCustomSettings() {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("SettingsParameter.getCustomSettings"); Query q = em.createNamedQuery("SettingsParameter.getCustomSettings");
...@@ -43,7 +52,11 @@ public class SettingsUtil { ...@@ -43,7 +52,11 @@ public class SettingsUtil {
return q.getResultList(); return q.getResultList();
} }
// Return a list of all settings /**
* Get a list of all settings
*
* @return all settings
*/
public static List<SettingsParameter> getCurrentSettings() { public static List<SettingsParameter> getCurrentSettings() {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("SettingsParameter.getCurrentSettings"); Query q = em.createNamedQuery("SettingsParameter.getCurrentSettings");
...@@ -51,7 +64,11 @@ public class SettingsUtil { ...@@ -51,7 +64,11 @@ public class SettingsUtil {
return q.getResultList(); return q.getResultList();
} }
// Update settings based on their name and value, and add new settings /**
* Update a given List of settings
*
* @param settings the settings to update
*/
public static void updateSettings(List<SettingsParameter> settings) { public static void updateSettings(List<SettingsParameter> settings) {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
EntityTransaction trans = em.getTransaction(); EntityTransaction trans = em.getTransaction();
...@@ -60,7 +77,7 @@ public class SettingsUtil { ...@@ -60,7 +77,7 @@ public class SettingsUtil {
for ( SettingsParameter setting : settings ) { for ( SettingsParameter setting : settings ) {
// Skip any empty settings // Skip any empty settings
if ( setting.getName().trim().isEmpty() || if ( setting.getName().trim().isEmpty() ||
setting.getValue().trim().isEmpty() ) { setting.getValue().trim().isEmpty() ) {
continue; continue;
} }
...@@ -82,6 +99,11 @@ public class SettingsUtil { ...@@ -82,6 +99,11 @@ public class SettingsUtil {
reloadSettings(); reloadSettings();
} }
/**
* Delete a given List of settings
*
* @param settings the settings to delete
*/
public static void deleteSettings(List<String> settings) { public static void deleteSettings(List<String> settings) {
EntityManager em = PersistUtil.getEntityManager(); EntityManager em = PersistUtil.getEntityManager();
EntityTransaction trans = em.getTransaction(); EntityTransaction trans = em.getTransaction();
...@@ -114,7 +136,12 @@ public class SettingsUtil { ...@@ -114,7 +136,12 @@ public class SettingsUtil {
} }
public static List<SettingsParameter> getDefaultSettings() { /**
* Get the default values for all settings
*
* @return the default settings
*/
public static List<SettingsParameter> getDefaultSettings() {
List<SettingsParameter> defaults = new ArrayList<>(); List<SettingsParameter> defaults = new ArrayList<>();
defaults.add(new SettingsParameter(SettingsConstants.PARAM_IMS, defaults.add(new SettingsParameter(SettingsConstants.PARAM_IMS,
...@@ -125,7 +152,7 @@ public class SettingsUtil { ...@@ -125,7 +152,7 @@ public class SettingsUtil {
SettingsConstants.imsSSL,false)); SettingsConstants.imsSSL,false));
defaults.add(new SettingsParameter(SettingsConstants.PARAM_IMS_TOKEN_CLASS, defaults.add(new SettingsParameter(SettingsConstants.PARAM_IMS_TOKEN_CLASS,
SettingsConstants.imsTokenClass,false)); SettingsConstants.imsTokenClass,false));
defaults.add(new SettingsParameter(SettingsConstants.PARAM_DISABLE_AUTO_AUDIT, defaults.add(new SettingsParameter(SettingsConstants.PARAM_AUTO_AUDIT_ENABLE,
SettingsConstants.autoAudit,false)); SettingsConstants.autoAudit,false));
defaults.add(new SettingsParameter(SettingsConstants.PARAM_THROTTLE_MAXAUDIT, defaults.add(new SettingsParameter(SettingsConstants.PARAM_THROTTLE_MAXAUDIT,
SettingsConstants.maxAudit,false)); SettingsConstants.maxAudit,false));
...@@ -173,11 +200,11 @@ public class SettingsUtil { ...@@ -173,11 +200,11 @@ public class SettingsUtil {
} }
/** /**
* *
* @param c The collection to query * @param c The collection to query
* @param attr The attribute to query for * @param attr The attribute to query for
* @return true if collection, settings are not null and parameter is "true" * @return true if collection, settings are not null and parameter is "true"
*/ */
public static boolean getBoolean(Collection c, String attr) { public static boolean getBoolean(Collection c, String attr) {
if (!containsKey(c, attr)) { if (!containsKey(c, attr)) {
return false; return false;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
Document : settings Document : settings
Created on : Jul 30, 2012, 4:07:16 PM Created on : Jul 30, 2012, 4:07:16 PM
Author : shake Author : shake
TODO: Enable sampling when we have it properly implemented
TODO: The Settings should come from a bean or smth so we can loop similar to the custom settings
--%> --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
...@@ -37,13 +39,6 @@ ...@@ -37,13 +39,6 @@
<div class="settingsVal"><input type=text name="throttle.maxaudit" value="${currSettings['throttle.maxaudit']}"/></div> <div class="settingsVal"><input type=text name="throttle.maxaudit" value="${currSettings['throttle.maxaudit']}"/></div>
<div class="settingsHelp"><img src="images/help.png" title="Max number of running audits"></div> <div class="settingsHelp"><img src="images/help.png" title="Max number of running audits"></div>
</div> </div>
<!-- TODO: Get proper sampling in the future
<div class="settingsRow">
<div class="settingsName">Audit Sampling:</div>
<div class="settingsVal"><input type=text name="audit.sample" value="${currSettings['audit.sample']}"/></div>
<div class="settingsHelp"><img src="images/help.png" title="Enable or disable statistical sampling while auditing (samples sqrt n files)"></div>
</div>
-->
<div class="settingsRow"> <div class="settingsRow">
<div class="settingsName">Audit IMS Blocking:</div> <div class="settingsName">Audit IMS Blocking:</div>
<div class="settingsVal"><input type=text name="audit.blocking" value="${currSettings['audit.blocking']}"/></div> <div class="settingsVal"><input type=text name="audit.blocking" value="${currSettings['audit.blocking']}"/></div>
...@@ -65,9 +60,9 @@ ...@@ -65,9 +60,9 @@
<div class="settingsHelp"><img src="images/help.png" title="Maximum bytes per second per running audit, default = 0 = unlimited"></div> <div class="settingsHelp"><img src="images/help.png" title="Maximum bytes per second per running audit, default = 0 = unlimited"></div>
</div> </div>
<div class="settingsRow"> <div class="settingsRow">
<div class="settingsName">Disable Auto Audit:</div> <div class="settingsName">Enable Auto Audit:</div>
<div class="settingsVal"><input type=text name="auto.audit.disable" value="${currSettings['auto.audit.disable']}"/></div> <div class="settingsVal"><input type=text name="auto.audit.enable" value="${currSettings['auto.audit.enable']}"/></div>
<div class="settingsHelp"><img src="images/help.png" title="Disable automated auditing"></div> <div class="settingsHelp"><img src="images/help.png" title="Enable automated auditing"></div>
</div> </div>
<div class="settingsRow"> <div class="settingsRow">
<div class="settingsName">Audit Only Mode:</div> <div class="settingsName">Audit Only Mode:</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment