From: <pn...@hy...> - 2009-02-06 22:17:52
|
Author: pnguyen Date: 2009-02-06 13:55:25 -0800 (Fri, 06 Feb 2009) New Revision: 12440 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=12440 Modified: trunk/src/org/hyperic/hq/events/AlertDefinitionInterface.java trunk/src/org/hyperic/hq/events/server/session/SessionBase.java Log: HQ-1295: updated SessionBase to support group alerts (reviewed by clee) Modified: trunk/src/org/hyperic/hq/events/AlertDefinitionInterface.java =================================================================== --- trunk/src/org/hyperic/hq/events/AlertDefinitionInterface.java 2009-02-06 21:50:55 UTC (rev 12439) +++ trunk/src/org/hyperic/hq/events/AlertDefinitionInterface.java 2009-02-06 21:55:25 UTC (rev 12440) @@ -33,6 +33,7 @@ public String getDescription(); public int getPriority(); public boolean isNotifyFiltered(); + public boolean isDeleted(); public boolean performsEscalations(); public Resource getResource(); } Modified: trunk/src/org/hyperic/hq/events/server/session/SessionBase.java =================================================================== --- trunk/src/org/hyperic/hq/events/server/session/SessionBase.java 2009-02-06 21:50:55 UTC (rev 12439) +++ trunk/src/org/hyperic/hq/events/server/session/SessionBase.java 2009-02-06 21:55:25 UTC (rev 12440) @@ -52,6 +52,7 @@ import org.hyperic.hq.authz.shared.PermissionManager; import org.hyperic.hq.authz.shared.PermissionManagerFactory; import org.hyperic.hq.common.shared.HQConstants; +import org.hyperic.hq.events.AlertDefinitionInterface; import org.hyperic.hq.events.EventConstants; import org.hyperic.hq.measurement.MeasurementConstants; import org.hyperic.hq.measurement.UnitsConvert; @@ -108,11 +109,16 @@ } } - protected AppdefEntityID getAppdefEntityID(AlertDefinition ad) { + public static AppdefEntityID getAppdefEntityID(AlertDefinitionInterface adi) { try { - return new AppdefEntityID(ad.getResource()); + return new AppdefEntityID(adi.getResource()); } catch (IllegalArgumentException e) { - return new AppdefEntityTypeID(ad.getAppdefType(), ad.getAppdefId()); + if (adi instanceof AlertDefinition) { + AlertDefinition ad = (AlertDefinition) adi; + return new AppdefEntityTypeID(ad.getAppdefType(), ad.getAppdefId()); + } else { + throw e; + } } } @@ -155,21 +161,25 @@ return ResourceManagerEJBImpl.getOne().findResource(id); } - protected void canManageAlerts(AuthzSubject who, AlertDefinition ad) + public static void canManageAlerts(AuthzSubject who, AlertDefinitionInterface adi) throws PermissionException { - if (ad.isDeleted()) // Don't need to check deleted alert defs + if (adi.isDeleted()) // Don't need to check deleted alert defs return; - Integer parentId = ad.getParent() != null ? ad.getParent().getId() - : null; + Integer parentId = null; + if (adi instanceof AlertDefinition) { + AlertDefinition ad = (AlertDefinition) adi; + parentId = ad.getParent() != null ? ad.getParent().getId() : null; + } + if (!EventConstants.TYPE_ALERT_DEF_ID.equals(parentId)) - canManageAlerts(who, getAppdefEntityID(ad)); + canManageAlerts(who, getAppdefEntityID(adi)); } /** * Check for manage alerts permission for a given resource */ - protected void canManageAlerts(AuthzSubject who, AppdefEntityID id) + public static void canManageAlerts(AuthzSubject who, AppdefEntityID id) throws PermissionException { if (id instanceof AppdefEntityTypeID) { // Make sure the user is a super user |