Author: dcrutchf Date: 2010-02-18 17:56:43 -0800 (Thu, 18 Feb 2010) New Revision: 14307 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14307 Modified: trunk/src/org/hyperic/hq/bizapp/server/session/GalertBossEJBImpl.java trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/ListAlertAction.java trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/PortalAction.java trunk/web/resource/common/monitor/alerts/ListAlerts.jsp Log: [HQ-2066] - User with no Fixed/Ack permission is able to see Ack icon on Alert list page for Group and Resouce alerts Modified: trunk/src/org/hyperic/hq/bizapp/server/session/GalertBossEJBImpl.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/server/session/GalertBossEJBImpl.java 2010-02-18 23:55:45 UTC (rev 14306) +++ trunk/src/org/hyperic/hq/bizapp/server/session/GalertBossEJBImpl.java 2010-02-19 01:56:43 UTC (rev 14307) @@ -45,6 +45,7 @@ import org.hyperic.hq.authz.server.session.ResourceGroup; import org.hyperic.hq.authz.server.session.ResourceGroupManagerEJBImpl; import org.hyperic.hq.authz.shared.PermissionException; +import org.hyperic.hq.bizapp.shared.AuthzBoss; import org.hyperic.hq.common.SystemException; import org.hyperic.hq.escalation.server.session.Escalatable; import org.hyperic.hq.escalation.server.session.Escalation; @@ -63,6 +64,7 @@ import org.hyperic.hq.galerts.server.session.GtriggerTypeInfo; import org.hyperic.hq.galerts.shared.GalertManagerLocal; import org.hyperic.hq.galerts.shared.GtriggerManagerLocal; +import org.hyperic.hq.ui.util.ContextUtils; import org.hyperic.util.TimeUtil; import org.hyperic.util.config.ConfigResponse; import org.hyperic.util.pager.PageControl; @@ -359,8 +361,10 @@ JSONArray jarr = new JSONArray(); try { - // ...check that user can view alert definitions... - SessionBase.canViewAlertDefinition(subj, new AppdefEntityID(g.getResource())); + AppdefEntityID entityId = new AppdefEntityID(g.getResource()); + + // ...check that user can view alert definitions... + SessionBase.canViewAlertDefinition(subj, entityId); alertLogs = _galertMan.findAlertLogsByTimeWindow(g, begin, end, pc); @@ -379,16 +383,27 @@ maxPauseTime = esc.getMaxPauseTime(); } + boolean canTakeAction = false; + + try { + // ...check that the user can fix/acknowledge... + SessionBase.canFixAcknowledgeAlerts(subj, entityId); + + canTakeAction = true; + } catch(PermissionException e) { + // ...the user can't fix/acknowledge... + } + jarr.put(new JSONObject() .put("id", alert.getId()) .put("time", date) .put("name", alert.getAlertDefinitionInterface().getName()) .put("defId", alert.getAlertDefinitionInterface().getId()) - .put("priority", - alert.getAlertDefinitionInterface().getPriority()) + .put("priority", alert.getAlertDefinitionInterface().getPriority()) .put("reason", alert.getShortReason()) .put("fixed", alert.isFixed()) .put("acknowledgeable", alert.isAcknowledgeable()) + .put("canTakeAction", canTakeAction) .put("maxPauseTime", maxPauseTime)); } } catch (PermissionException e) { Modified: trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/ListAlertAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/ListAlertAction.java 2010-02-18 23:55:45 UTC (rev 14306) +++ trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/ListAlertAction.java 2010-02-19 01:56:43 UTC (rev 14307) @@ -153,8 +153,6 @@ } catch(PermissionException e) { // ...the user can't fix/acknowledge... } - - request.setAttribute(Constants.CAN_TAKE_ACTION_ON_ALERT_ATTR, canTakeAction); for (Iterator<Alert> itr = alerts.iterator();itr.hasNext();) { Alert alert = itr.next(); Modified: trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/PortalAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/PortalAction.java 2010-02-18 23:55:45 UTC (rev 14306) +++ trunk/src/org/hyperic/hq/ui/action/resource/common/monitor/alerts/PortalAction.java 2010-02-19 01:56:43 UTC (rev 14307) @@ -40,6 +40,9 @@ import org.apache.struts.action.ActionMapping; import org.apache.struts.util.MessageResources; import org.hyperic.hq.appdef.shared.AppdefEntityID; +import org.hyperic.hq.authz.server.session.AuthzSubject; +import org.hyperic.hq.authz.shared.PermissionException; +import org.hyperic.hq.bizapp.shared.AuthzBoss; import org.hyperic.hq.bizapp.shared.EventsBoss; import org.hyperic.hq.bizapp.shared.GalertBoss; import org.hyperic.hq.escalation.server.session.Escalatable; @@ -47,6 +50,7 @@ import org.hyperic.hq.events.server.session.Alert; import org.hyperic.hq.events.server.session.AlertDefinition; import org.hyperic.hq.events.server.session.ClassicEscalationAlertType; +import org.hyperic.hq.events.server.session.SessionBase; import org.hyperic.hq.events.shared.AlertDefinitionValue; import org.hyperic.hq.events.shared.AlertValue; import org.hyperic.hq.galerts.server.session.GalertEscalationAlertType; @@ -119,8 +123,28 @@ Portal portal = Portal.createPortal(); AppdefEntityID aeid = RequestUtils.getEntityId(request); + + boolean canTakeAction = false; + + try { + ServletContext ctx = getServlet().getServletContext(); + int sessionId = RequestUtils.getSessionId(request).intValue(); + AuthzBoss authzBoss = ContextUtils.getAuthzBoss(ctx); + AuthzSubject subject = authzBoss.getCurrentSubject(sessionId); + + // ...check that the user can fix/acknowledge... + SessionBase.canFixAcknowledgeAlerts(subject, aeid); + + canTakeAction = true; + } catch(PermissionException e) { + // ...the user can't fix/acknowledge... + } + + request.setAttribute(Constants.CAN_TAKE_ACTION_ON_ALERT_ATTR, canTakeAction); + setTitle(aeid, portal, "alerts.alert.platform.AlertList.Title"); portal.setDialog(false); + if (aeid.isGroup()) { portal.addPortlet(new Portlet(".events.group.alert.list"), 1); Modified: trunk/web/resource/common/monitor/alerts/ListAlerts.jsp =================================================================== --- trunk/web/resource/common/monitor/alerts/ListAlerts.jsp 2010-02-18 23:55:45 UTC (rev 14306) +++ trunk/web/resource/common/monitor/alerts/ListAlerts.jsp 2010-02-19 01:56:43 UTC (rev 14307) @@ -351,7 +351,7 @@ <display:column width="7%" property="fixed" title="alerts.alert.AlertList.ListHeader.Fixed"> <display:booleandecorator flagKey="yesno"/> </display:column> - <display:column width="11%" property="acknowledgeable" title="alerts.alert.AlertList.ListHeader.Acknowledge" + <display:column width="11%" property="acknowledgeableAndCanTakeAction" title="alerts.alert.AlertList.ListHeader.Acknowledge" href="/alerts/RemoveAlerts.do?eid=${Resource.entityId.appdefKey}&alerts=${Alert.id}&buttonAction=ACKNOWLEDGE"> <display:booleandecorator flagKey="acknowledgeable"/> </display:column> |