public String raiseAlarm ( NotificationSourceWrapper notificationSource , String alarmType , String instanceID , AlarmLevel level , String message , Throwable cause ) { synchronized ( notificationSource ) { if ( isAlarmAlive ( notificationSource , alarmType , instanceID ) ) { // Alarm a = this.placeHolderToAlarm.get(new // AlarmPlaceHolder(notificationSource, alarmType, instanceID)); Alarm a = null ; // unconveniant.... try { AlarmPlaceHolder localAPH = new AlarmPlaceHolder ( notificationSource , alarmType , instanceID ) ; for ( Map . Entry < String , AlarmPlaceHolder > e : this . alarmIdToAlarm . entrySet ( ) ) { if ( e . getValue ( ) . equals ( localAPH ) ) { a = e . getValue ( ) . getAlarm ( ) ; break ; } } } catch ( Exception e ) { // ignore } if ( a != null ) { return a . getAlarmID ( ) ; } else { return this . raiseAlarm ( notificationSource , alarmType , instanceID , level , message , cause ) ; } } else { Alarm a = new Alarm ( UUID . randomUUID ( ) . toString ( ) , notificationSource . getNotificationSource ( ) , alarmType , instanceID , level , message , cause , System . currentTimeMillis ( ) ) ; AlarmPlaceHolder aph = new AlarmPlaceHolder ( notificationSource , alarmType , instanceID , a ) ; this . alarmIdToAlarm . put ( a . getAlarmID ( ) , aph ) ; // this.placeHolderToAlarm.put(aph, a); this . placeHolderToNotificationSource . put ( aph , aph . getNotificationSource ( ) . getNotificationSource ( ) ) ; generateNotification ( aph , false ) ; return a . getAlarmID ( ) ; } } }
THis methods raises alarm . It MUST not receive AlarmLevel . CLEAR it has to be filtered .