Author: pnguyen Date: 2010-05-14 17:37:43 -0700 (Fri, 14 May 2010) New Revision: 14598 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14598 Modified: trunk/src/org/hyperic/hq/bizapp/Resources.properties trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java trunk/src/org/hyperic/hq/ui/action/resource/hub/RemoveResourceAction.java trunk/web/WEB-INF/classes/ApplicationResources.properties Log: [HHQ-3772] If there is a scheduler error, prevent the delete from occurring Modified: trunk/src/org/hyperic/hq/bizapp/Resources.properties =================================================================== --- trunk/src/org/hyperic/hq/bizapp/Resources.properties 2010-05-14 22:12:30 UTC (rev 14597) +++ trunk/src/org/hyperic/hq/bizapp/Resources.properties 2010-05-15 00:37:43 UTC (rev 14598) @@ -19,3 +19,7 @@ alert.threshold.subject.end.message=HQ alert storm has ended alert.threshold.subject.continue.message=HQ alert storm update alert.threshold.subject.begin.message=HQ alert storm in progress + +resource.groups.remove.error.downtime.exists=Could not remove {0} because a downtime schedule exists. +resource.groups.remove.error.downtime.scheduler.failure=Could not remove {0} because of a scheduler error. + Modified: trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java 2010-05-14 22:12:30 UTC (rev 14597) +++ trunk/src/org/hyperic/hq/bizapp/server/session/AppdefBossEJBImpl.java 2010-05-15 00:37:43 UTC (rev 14598) @@ -6,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004-2009], Hyperic, Inc. + * Copyright (C) [2004-2010], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -25,6 +25,7 @@ package org.hyperic.hq.bizapp.server.session; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -36,6 +37,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.ResourceBundle; import java.util.Set; import java.util.TreeSet; import java.util.regex.PatternSyntaxException; @@ -198,6 +200,8 @@ extends BizappSessionEJB implements SessionBean { + private final String BUNDLE = "org.hyperic.hq.bizapp.Resources"; + private final String APPDEF_PAGER_PROCESSOR = "org.hyperic.hq.appdef.shared.pager.AppdefPagerProc"; @@ -1323,14 +1327,24 @@ getEventsBoss().getMaintenanceEvent(sessionId, aeid.getId()); if (event != null && event.getStartTime() != 0) { - throw new VetoException("Could not remove resource " + aeid + - " because a downtime schedule exists."); + String msg = ResourceBundle.getBundle(BUNDLE) + .getString("resource.groups.remove.error.downtime.exists"); + + throw new VetoException( + MessageFormat.format(msg, new String[] {res.getName()})); } - } catch (Throwable t) { + } catch (SchedulerException se) { // HHQ-3772: This should not happen. However, if it does, - // log the exception as a warning and continue with the delete. - log.warn("Failure getting the downtime schedule for group[" + aeid + "]. " - + "Ignoring and continuing with the delete process.", t); + // log the exception as a warning and do not allow to delete + // until the scheduler issue is resolved + log.warn("Scheduler error getting the downtime schedule for group[" + aeid + "]: " + + se.getMessage(), se); + + String msg = ResourceBundle.getBundle(BUNDLE) + .getString("resource.groups.remove.error.downtime.scheduler.failure"); + + throw new VetoException( + MessageFormat.format(msg, new String[] {res.getName()})); } } if (res == null) { Modified: trunk/src/org/hyperic/hq/ui/action/resource/hub/RemoveResourceAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/action/resource/hub/RemoveResourceAction.java 2010-05-14 22:12:30 UTC (rev 14597) +++ trunk/src/org/hyperic/hq/ui/action/resource/hub/RemoveResourceAction.java 2010-05-15 00:37:43 UTC (rev 14598) @@ -6,7 +6,7 @@ * normal use of the program, and does *not* fall under the heading of * "derived work". * - * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. + * Copyright (C) [2004-2010], Hyperic, Inc. * This file is part of HQ. * * HQ is free software; you can redistribute it and/or modify @@ -138,7 +138,7 @@ BizappUtils.buildAppdefEntityIds(resourceList); if (resourceItems != null && resourceItems.length > 0) { Set deleted = new HashSet(); - int vetoed = 0; + String vetoMessage = null; // about the exception handling: // if someone either deleted the entity out from under our user // or the user hit the back button, a derivative of @@ -156,15 +156,16 @@ log.error("Removing resource " + resourceId + "failed."); } catch (VetoException v) { - vetoed++; - log.info(v.getMessage()); + vetoMessage = v.getMessage(); + log.info(vetoMessage); } } - if (vetoed > 0) { + if (vetoMessage != null) { RequestUtils - .setError(request, - "resource.common.inventory.groups.error.RemoveVetoed"); + .setErrorObject(request, + "resource.common.inventory.groups.error.RemoveVetoed", + vetoMessage); } else if (deleted.size() > 0) { RequestUtils .setConfirmation(request, Modified: trunk/web/WEB-INF/classes/ApplicationResources.properties =================================================================== --- trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-05-14 22:12:30 UTC (rev 14597) +++ trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-05-15 00:37:43 UTC (rev 14598) @@ -1127,7 +1127,7 @@ resource.common.inventory.error.ReportTypeIsRequired=report type not specified resource.common.inventory.error.ReportNameRequired=report name not specified resource.common.inventory.groups.NewGroupsTab=Groups not containing this resource -resource.common.inventory.groups.error.RemoveVetoed=Could not remove the selected group(s) because a downtime schedule exists. +resource.common.inventory.groups.error.RemoveVetoed={0} # security resource.common.inventory.security.SecurityTH=Security |