protected void sendWardenEmailToUser ( NotificationContext context , SubSystem subSystem ) { EntityManager em = emf . get ( ) ; PrincipalUser user = getWardenUser ( context . getAlert ( ) . getName ( ) ) ; SuspensionRecord record = SuspensionRecord . findByUserAndSubsystem ( em , user , subSystem ) ; Set < String > to = new HashSet <> ( ) ; to . add ( user . getEmail ( ) ) ; String subject = "Warden Email Notification" ; StringBuilder message = new StringBuilder ( ) ; message . append ( MessageFormat . format ( "<p>{0} has been suspended from the Argus system for violating the following policy</p>" , user . getUserName ( ) ) ) ; message . append ( MessageFormat . format ( "Subsystem: {0}" , subSystem . toString ( ) ) ) ; message . append ( MessageFormat . format ( "<br>Policy: {0}" , context . getAlert ( ) . getName ( ) . replace ( WARDEN_ALERT_NAME_PREFIX + user . getUserName ( ) + "-" , "" ) ) ) ; message . append ( MessageFormat . format ( "<br>Threshold: {0}" , context . getAlert ( ) . getTriggers ( ) . get ( 0 ) . getThreshold ( ) ) ) ; message . append ( MessageFormat . format ( "<br>Triggering Value: {0}" , context . getTriggerEventValue ( ) ) ) ; if ( record . getSuspendedUntil ( ) == - 1 ) { message . append ( "<br> You have been suspended indefinitely" ) ; } else { message . append ( MessageFormat . format ( "<br>Reinstatement Time: {0}" , DATE_FORMATTER . get ( ) . format ( new Date ( record . getSuspendedUntil ( ) ) ) ) ) ; } _mailService . sendMessage ( to , subject , message . toString ( ) , "text/html; charset=utf-8" , MailService . Priority . HIGH ) ; to . clear ( ) ; to . add ( "argus-admin@salesforce.com" ) ; message . append ( "<p><a href='" ) . append ( getAlertUrl ( context . getAlert ( ) . getId ( ) ) ) . append ( "'>Click here to view alert definition.</a><br/>" ) ; _mailService . sendMessage ( to , subject , message . toString ( ) , "text/html; charset=utf-8" , MailService . Priority . HIGH ) ; }
Sends an email to user and admin with information on suspension and when user will be reinstated .