|
From: <cl...@hy...> - 2007-03-22 19:43:21
|
Author: clee Date: 2007-03-22 11:43:07 -0800 (Thu, 22 Mar 2007) New Revision: 3818 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=3818 Modified: trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_alertdef_create.java trunk/src/org/hyperic/hq/events/EventConstants.java trunk/src/org/hyperic/util/config/EnumerationConfigOption.java Log: [HQ-588] An Alert Fired condition is not a valid condition, it's a hidden one used for Recovery Alerts. Remove from CLI. Modified: trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_alertdef_create.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_alertdef_create.java 2007-03-22 18:38:31 UTC (rev 3817) +++ trunk/src/org/hyperic/hq/bizapp/client/shell/ClientShell_alertdef_create.java 2007-03-22 19:43:07 UTC (rev 3818) @@ -111,7 +111,7 @@ throws ShellCommandExecException { try { - metrics = this.getEntityFetcher().getMetricsForID(id); + metrics = getEntityFetcher().getMetricsForID(id); if (metrics.size() == 0) return ""; } catch (Exception exc) { @@ -223,7 +223,7 @@ public void processCommand(ParseResult parseRes) throws ShellCommandUsageException, ShellCommandExecException { - ClientShellEntityFetcher fetcher = this.getEntityFetcher(); + ClientShellEntityFetcher fetcher = getEntityFetcher(); // build a list of resource objects List resources = new PageList(); @@ -234,11 +234,11 @@ .getValue(ClientShellParseUtil.KEY_RESOURCE); resources.add(fetcher.findResourceByID(eid)); - createResp = this.getClientShell().processConfigSchema( - this.getDefCreateSchema()); + createResp = getClientShell().processConfigSchema( + getDefCreateSchema()); } catch (EOFException exc) { - this.getOutStream().println("\nAlert definition creation aborted"); + getOutStream().println("\nAlert definition creation aborted"); return; } catch (Exception exc) { throw new ShellCommandExecException(exc.getMessage(), exc); @@ -266,8 +266,8 @@ boolean req = true; try { // Need to find out what type of alert the user wants - typeResp = this.getClientShell() - .processConfigSchema(this.getCondTypeSchema()); + typeResp = getClientShell() + .processConfigSchema(getCondTypeSchema()); int type = EventConstants.getType(typeResp.getValue(PROP_OPTION)); @@ -280,7 +280,7 @@ reqMap.put(condResp, Boolean.valueOf(req)); // get the email and user ids for the alertdef from the user - ConfigSchema emailActionSchema = this.getEntityFetcher() + ConfigSchema emailActionSchema = getEntityFetcher() .getActionConfigSchema(new EmailActionConfig() .getImplementor()); getClientShell().getOutStream() @@ -294,7 +294,7 @@ // to supply a proper value while ( true ) { try { - if (this.getEntityFetcher().ensureNamesAreIds(actionResp)) { + if (getEntityFetcher().ensureNamesAreIds(actionResp)) { break; } actionResp = getClientShell() @@ -323,7 +323,7 @@ "An invalid option was entered.", e); } catch (Exception e) { throw new ShellCommandExecException( - "An exception has occured creating alert definition.", e); + "An exception has occured creating alert definition." + e.getMessage(), e); } } @@ -375,7 +375,7 @@ try { // now save the alert definition in the backend - clone = this.getEntityFetcher().createAlertDefinition(clone); + clone = getEntityFetcher().createAlertDefinition(clone); getShell().sendToOutStream("Alert Definition '" + def.getName() + "' (ID: " + clone.getId() + ") has been added to resource '" + @@ -418,14 +418,14 @@ case EventConstants.TYPE_BASELINE : case EventConstants.TYPE_CHANGE: // Print out metrics - this.getOutStream().println(getMetricAliases(id)); + getOutStream().println(getMetricAliases(id)); break; default: break; } ConfigResponse condResp = - this.getClientShell().processConfigSchema(condSchema); + getClientShell().processConfigSchema(condSchema); return condResp; } @@ -457,7 +457,7 @@ public String getUsageHelp(String[] args) { return " " - + this.getUsageShort() + + getUsageShort() + ".\n" + "\n The command will prompt for alert definition properties." + "\n Adding measurement related conditions requires the alias of" Modified: trunk/src/org/hyperic/hq/events/EventConstants.java =================================================================== --- trunk/src/org/hyperic/hq/events/EventConstants.java 2007-03-22 18:38:31 UTC (rev 3817) +++ trunk/src/org/hyperic/hq/events/EventConstants.java 2007-03-22 19:43:07 UTC (rev 3818) @@ -40,11 +40,11 @@ public static final int TYPE_LOG = 7; private static final String[] TYPES = { - "Measurement Threshold", - "Measurement Baseline", + "Metric Threshold", + "Metric Baseline", "Control Action", - "Measurement Value Change", - "Alert Fired", + "Metric Value Change", + "", // Don't want Recovery Alert condition to be visible "Custom Property Value Change", "Log Event", }; Modified: trunk/src/org/hyperic/util/config/EnumerationConfigOption.java =================================================================== --- trunk/src/org/hyperic/util/config/EnumerationConfigOption.java 2007-03-22 18:38:31 UTC (rev 3817) +++ trunk/src/org/hyperic/util/config/EnumerationConfigOption.java 2007-03-22 19:43:07 UTC (rev 3818) @@ -31,7 +31,7 @@ public class EnumerationConfigOption extends ConfigOption implements Serializable { - private ArrayList values = new ArrayList(); /* Values the enum holds */ + private ArrayList _values = new ArrayList(); // Values the enum holds public EnumerationConfigOption(String optName, String optDesc, String defValue) @@ -47,16 +47,18 @@ String defValue, String[] enumValues) { super(optName, optDesc, defValue); - for(int i=0; i<enumValues.length; i++){ - this.values.add(enumValues[i]); + for (int i = 0; i < enumValues.length; i++) { + if (enumValues[i] != null && enumValues[i].length() > 0) { + _values.add(enumValues[i]); + } } } public void checkOptionIsValid(String value) throws InvalidOptionValueException { - if (!this.values.contains(value)) { - throw invalidOption("must be one of: " + this.values); + if (!_values.contains(value)) { + throw invalidOption("must be one of: " + _values); } } @@ -64,9 +66,9 @@ String defVal = super.getDefault(); //if no default was specified, use the first in the list if ((defVal == null) && - (this.values.size() != 0)) + (_values.size() != 0)) { - defVal = (String)this.values.get(0); + defVal = (String)_values.get(0); } return defVal; } @@ -76,10 +78,10 @@ **********************/ public void addValue(String option){ - this.values.add(option); + _values.add(option); } public List getValues(){ - return this.values; + return _values; } } |