public static void updateProjectNotifications ( final Project project , final ProjectManager pm ) throws ProjectManagerException { final Flow flow = project . getFlows ( ) . get ( 0 ) ; // Get all success emails. final ArrayList < String > successEmails = new ArrayList <> ( ) ; final String successNotifications = ( String ) project . getMetadata ( ) . get ( "notifications" ) ; final String [ ] successEmailSplit = successNotifications . split ( "\\s*,\\s*|\\s*;\\s*|\\s+" ) ; successEmails . addAll ( Arrays . asList ( successEmailSplit ) ) ; // Get all failure emails. final ArrayList < String > failureEmails = new ArrayList <> ( ) ; final String failureNotifications = ( String ) project . getMetadata ( ) . get ( "failureNotifications" ) ; final String [ ] failureEmailSplit = failureNotifications . split ( "\\s*,\\s*|\\s*;\\s*|\\s+" ) ; failureEmails . addAll ( Arrays . asList ( failureEmailSplit ) ) ; // Add subscription emails to success emails list. @ SuppressWarnings ( "unchecked" ) final Map < String , String > subscription = ( Map < String , String > ) project . getMetadata ( ) . get ( "subscription" ) ; if ( subscription != null ) { successEmails . addAll ( subscription . values ( ) ) ; } final ArrayList < String > successEmailList = new ArrayList <> ( ) ; for ( final String email : successEmails ) { if ( ! email . trim ( ) . isEmpty ( ) ) { successEmailList . add ( email ) ; } } final ArrayList < String > failureEmailList = new ArrayList <> ( ) ; for ( final String email : failureEmails ) { if ( ! email . trim ( ) . isEmpty ( ) ) { failureEmailList . add ( email ) ; } } // Save notifications in the flow. flow . getSuccessEmails ( ) . clear ( ) ; flow . getFailureEmails ( ) . clear ( ) ; flow . addSuccessEmails ( successEmailList ) ; flow . addFailureEmails ( failureEmailList ) ; pm . updateFlow ( project , flow ) ; }
Updates the email notifications saved in the project s flow .