Author: jtravis
Date: 2007-07-13 14:32:45 -0700 (Fri, 13 Jul 2007)
New Revision: 5203
URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=5203
Added:
trunk/src/org/hyperic/hq/events/server/session/AlertableRoleCalendarType.java
Modified:
trunk/src/org/hyperic/hq/authz/Resources.properties
trunk/src/org/hyperic/hq/authz/server/session/Role.java
trunk/src/org/hyperic/hq/authz/server/session/RoleCalendarType.java
trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java
trunk/src/org/hyperic/hq/common/server/session/Calendar.java
trunk/src/org/hyperic/hq/events/Resources.properties
trunk/src/org/hyperic/hq/events/server/session/EventsStartupListener.java
Log:
Remove logic about alerts from roles. Instead, create a subclass of the enumeration in events
Modified: trunk/src/org/hyperic/hq/authz/Resources.properties
===================================================================
--- trunk/src/org/hyperic/hq/authz/Resources.properties 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/authz/Resources.properties 2007-07-13 21:32:45 UTC (rev 5203)
@@ -1 +0,0 @@
-roleCalendar.alertable=alertable
Modified: trunk/src/org/hyperic/hq/authz/server/session/Role.java
===================================================================
--- trunk/src/org/hyperic/hq/authz/server/session/Role.java 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/authz/server/session/Role.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import org.hyperic.hq.authz.shared.RoleValue;
import org.hyperic.hq.authz.values.OwnedRoleValue;
@@ -132,6 +133,22 @@
_calendars = c;
}
+ /**
+ * Get a collection of {@link Calendar}s of the specified type for the
+ * role.
+ */
+ public Collection getCalendars(RoleCalendarType type) {
+ List res = new ArrayList();
+
+ for (Iterator i=getCalendars().iterator(); i.hasNext(); ) {
+ RoleCalendar c = (RoleCalendar)i.next();
+
+ if (c.getType().equals(type))
+ res.add(c.getCalendar());
+ }
+ return res;
+ }
+
public Collection getCalendars() {
return Collections.unmodifiableCollection(_calendars);
}
Modified: trunk/src/org/hyperic/hq/authz/server/session/RoleCalendarType.java
===================================================================
--- trunk/src/org/hyperic/hq/authz/server/session/RoleCalendarType.java 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/authz/server/session/RoleCalendarType.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -29,16 +29,13 @@
import org.hyperic.util.HypericEnum;
-public class RoleCalendarType
+public abstract class RoleCalendarType
extends HypericEnum
{
- private static final String BUNDLE = "org.hyperic.hq.authz.Resources";
-
- public static final RoleCalendarType ALERTABLE =
- new RoleCalendarType(0, "alertable", "roleCalendar.alertable");
-
- private RoleCalendarType(int code, String desc, String localeProp) {
- super(code, desc, localeProp, ResourceBundle.getBundle(BUNDLE));
+ protected RoleCalendarType(int code, String desc, String localeProp,
+ ResourceBundle bundle)
+ {
+ super(RoleCalendarType.class, code, desc, localeProp, bundle);
}
public static RoleCalendarType findByCode(int code) {
Modified: trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java
===================================================================
--- trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/authz/server/session/RoleManagerEJBImpl.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -657,29 +657,6 @@
}
/**
- * @ejb:interface-method
- */
- public boolean isRoleOnCall(Role role, RoleCalendarType type) {
- Collection calendars = role.getCalendars();
- if (calendars.size() == 0)
- return true;
-
- long current = System.currentTimeMillis();
- for (Iterator it = calendars.iterator(); it.hasNext(); ) {
- RoleCalendar rc = (RoleCalendar) it.next();
- if (rc.getType().equals(type)) {
- Collection entries = rc.getCalendar().getEntries();
- for (Iterator eit = entries.iterator(); it.hasNext(); ) {
- WeekEntry we = (WeekEntry) eit.next();
- if (we.containsTime(current))
- return true;
- }
- }
- }
- return false;
- }
-
- /**
* Create a calendar under a role for a specific type. Calendars created
* in this manner are tied directly to the role and should not be used
* by other roles.
Modified: trunk/src/org/hyperic/hq/common/server/session/Calendar.java
===================================================================
--- trunk/src/org/hyperic/hq/common/server/session/Calendar.java 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/common/server/session/Calendar.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -28,8 +28,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Iterator;
import org.hyperic.hibernate.PersistedObject;
+import org.hyperic.hq.authz.server.session.RoleCalendar;
public class Calendar
extends PersistedObject
@@ -74,6 +76,15 @@
return res;
}
+ public boolean containsTime(long time) {
+ for (Iterator i = getEntries().iterator(); i.hasNext(); ) {
+ CalendarEntry ent = (CalendarEntry)i.next();
+ if (ent.containsTime(time))
+ return true;
+ }
+ return false;
+ }
+
public String toString() {
return "Calendar[" + getName() + "]";
}
Modified: trunk/src/org/hyperic/hq/events/Resources.properties
===================================================================
--- trunk/src/org/hyperic/hq/events/Resources.properties 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/events/Resources.properties 2007-07-13 21:32:45 UTC (rev 5203)
@@ -8,3 +8,5 @@
alert.sortField.ackedBy=Acked By
alert.sortField.severity=Severity
escalation.type.classic=Classic
+roleCalendar.alertable=alertable
+roleCalendar.notAlertable=not alertable
Added: trunk/src/org/hyperic/hq/events/server/session/AlertableRoleCalendarType.java
===================================================================
--- trunk/src/org/hyperic/hq/events/server/session/AlertableRoleCalendarType.java (rev 0)
+++ trunk/src/org/hyperic/hq/events/server/session/AlertableRoleCalendarType.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -0,0 +1,51 @@
+/*
+ * NOTE: This copyright does *not* cover user programs that use HQ
+ * program services by normal system calls through the application
+ * program interfaces provided as part of the Hyperic Plug-in Development
+ * Kit or the Hyperic Client Development Kit - this is merely considered
+ * normal use of the program, and does *not* fall under the heading of
+ * "derived work".
+ *
+ * Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
+ * This file is part of HQ.
+ *
+ * HQ is free software; you can redistribute it and/or modify
+ * it under the terms version 2 of the GNU General Public License as
+ * published by the Free Software Foundation. This program is distributed
+ * in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA.
+ */
+
+package org.hyperic.hq.events.server.session;
+
+import java.util.ResourceBundle;
+
+import org.hyperic.hq.authz.server.session.RoleCalendarType;
+
+public class AlertableRoleCalendarType
+ extends RoleCalendarType
+{
+ private static final String BUNDLE = "org.hyperic.hq.events.Resources";
+
+ public static final AlertableRoleCalendarType ALERTABLE =
+ new AlertableRoleCalendarType(1001, "alertable",
+ "roleCalendar.alertable",
+ ResourceBundle.getBundle(BUNDLE));
+ public static final AlertableRoleCalendarType NOT_ALERTABLE =
+ new AlertableRoleCalendarType(1002, "notAlertable",
+ "roleCalendar.notAlertable",
+ ResourceBundle.getBundle(BUNDLE));
+
+ private AlertableRoleCalendarType(int code, String desc, String localeProp,
+ ResourceBundle bundle)
+ {
+ super(code, desc, localeProp, bundle);
+ }
+}
Modified: trunk/src/org/hyperic/hq/events/server/session/EventsStartupListener.java
===================================================================
--- trunk/src/org/hyperic/hq/events/server/session/EventsStartupListener.java 2007-07-13 19:02:02 UTC (rev 5202)
+++ trunk/src/org/hyperic/hq/events/server/session/EventsStartupListener.java 2007-07-13 21:32:45 UTC (rev 5203)
@@ -49,7 +49,8 @@
// Make sure the escalation enumeration is loaded and registered so
// that the escalations run
ClassicEscalationAlertType.class.getClass();
-
+ AlertableRoleCalendarType.class.getClass();
+
HQApp app = HQApp.getInstance();
synchronized (LOCK) {
|