private void getProjectGroupNotifiers( ProjectGroup projectGroup, Map<String, List<ProjectNotifier>> notifiersMap ) { // perform the project group level notifications if ( projectGroup.getNotifiers() != null ) { for ( ProjectNotifier projectNotifier : (List<ProjectNotifier>) projectGroup.getNotifiers() ) { List<ProjectNotifier> projectNotifiers = notifiersMap.get( projectNotifier.getType() ); if ( projectNotifiers == null ) { projectNotifiers = new ArrayList<ProjectNotifier>(); } if ( !projectNotifier.isEnabled() ) { log.info( projectNotifier.getType() + " projectNotifier (id=" + projectNotifier.getId() + ") is disabled." ); continue; } projectNotifiers.add( projectNotifier ); notifiersMap.put( projectNotifier.getType(), projectNotifiers ); } } } }
private void getProjectNotifiers( Project project, Map<String, List<ProjectNotifier>> notifiersMap ) { if ( project.getNotifiers() != null ) { // perform the project level notifications for ( ProjectNotifier notifier : (List<ProjectNotifier>) project.getNotifiers() ) { List<ProjectNotifier> notifiers = notifiersMap.get( notifier.getType() ); if ( notifiers == null ) { notifiers = new ArrayList<ProjectNotifier>(); } if ( !notifier.isEnabled() ) { log.info( notifier.getType() + " notifier (id=" + notifier.getId() + ") is disabled." ); continue; } notifiers.add( notifier ); notifiersMap.put( notifier.getType(), notifiers ); } } }
private void sendNotification( String messageId, MessageContext context ) { String notifierType = context.getNotifiers().get( 0 ).getType(); try { Notifier notifier = notifierManager.getNotifier( notifierType ); notifier.sendMessage( messageId, context ); } catch ( NotificationException e ) { log.error( "Error while trying to use the " + notifierType + " notifier.", e ); } }
public void assertProjectEquals( String name, List<ProjectNotifier> notifiers, String version, Project actual ) { assertEquals( "project.name", name, actual.getName() ); // assertEquals( "project.scmUrl", scmUrl, actual.getScmUrl() ); if ( notifiers != null ) { assertNotNull( "project.notifiers", actual.getNotifiers() ); assertEquals( "project.notifiers.size", notifiers.size(), actual.getNotifiers().size() ); for ( int i = 0; i < notifiers.size(); i++ ) { ProjectNotifier notifier = notifiers.get( i ); ProjectNotifier actualNotifier = (ProjectNotifier) actual.getNotifiers().get( i ); assertEquals( "project.notifiers.notifier.type", notifier.getType(), actualNotifier.getType() ); assertEquals( "project.notifiers.notifier.configuration.address", notifier.getConfiguration().get( "address" ), actualNotifier.getConfiguration().get( "address" ) ); } } assertEquals( "project.version", version, actual.getVersion() ); }
public void assertProjectEquals( String name, List notifiers, String version, Project actual ) { assertEquals( "project.name", name, actual.getName() ); // assertEquals( "project.scmUrl", scmUrl, actual.getScmUrl() ); if ( notifiers != null ) { assertNotNull( "project.notifiers", actual.getNotifiers() ); assertEquals( "project.notifiers.size", notifiers.size(), actual.getNotifiers().size() ); for ( int i = 0; i < notifiers.size(); i++ ) { ProjectNotifier notifier = (ProjectNotifier) notifiers.get( i ); ProjectNotifier actualNotifier = (ProjectNotifier) actual.getNotifiers().get( i ); assertEquals( "project.notifiers.notifier.type", notifier.getType(), actualNotifier.getType() ); assertEquals( "project.notifiers.notifier.configuration.address", notifier.getConfiguration().get( "address" ), actualNotifier.getConfiguration().get( "address" ) ); } } assertEquals( "project.version", version, actual.getVersion() ); }
if ( "mail".equals( notifier.getType() ) )
private void sendNotification( String messageId, ProjectNotifier projectNotifier, Map context ) { String notifierType = projectNotifier.getType(); if ( !projectNotifier.isEnabled() ) { getLogger().info( notifierType + " notifier (id=" + projectNotifier.getId() + ") is disabled." ); return; } Map configuration = projectNotifier.getConfiguration(); try { context.put( CONTEXT_PROJECT_NOTIFIER, projectNotifier ); Notifier notifier = notifierManager.getNotifier( notifierType ); Set recipients = recipientSource.getRecipients( String.valueOf( projectNotifier.getId() ), messageId, configuration, context ); notifier.sendNotification( messageId, recipients, configuration, context ); } catch ( NotificationException e ) { getLogger().error( "Error while trying to use the " + notifierType + " notifier.", e ); } } }
if ( StringUtils.isEmpty( notifier.getType() ) )
userNotifier.setType( notifier.getType() );
if ( StringUtils.isEmpty( notifier.getType() ) )
userNotifier.setType( notifier.getType() );
public ProjectNotifier addNotifier( int projectId, ProjectNotifier notifier ) throws ContinuumException { ProjectNotifier notif = new ProjectNotifier(); notif.setSendOnSuccess( notifier.isSendOnSuccess() ); notif.setSendOnFailure( notifier.isSendOnFailure() ); notif.setSendOnError( notifier.isSendOnError() ); notif.setSendOnWarning( notifier.isSendOnWarning() ); notif.setConfiguration( notifier.getConfiguration() ); notif.setType( notifier.getType() ); notif.setFrom( ProjectNotifier.FROM_USER ); Project project = getProjectWithAllDetails( projectId ); project.addNotifier( notif ); updateProject( project ); return notif; }
userNotifier.setType( notifier.getType() );
public ProjectNotifier addNotifier( int projectId, ProjectNotifier notifier ) throws ContinuumException { ProjectNotifier notif = new ProjectNotifier(); notif.setSendOnSuccess( notifier.isSendOnSuccess() ); notif.setSendOnFailure( notifier.isSendOnFailure() ); notif.setSendOnError( notifier.isSendOnError() ); notif.setSendOnWarning( notifier.isSendOnWarning() ); notif.setSendOnScmFailure( notifier.isSendOnScmFailure() ); notif.setConfiguration( notifier.getConfiguration() ); notif.setType( notifier.getType() ); notif.setFrom( ProjectNotifier.FROM_USER ); Project project = getProjectWithAllDetails( projectId ); project.addNotifier( notif ); updateProject( project ); return notif; }
public ProjectNotifier addGroupNotifier( int projectGroupId, ProjectNotifier notifier ) throws ContinuumException { ProjectNotifier notif = new ProjectNotifier(); notif.setSendOnSuccess( notifier.isSendOnSuccess() ); notif.setSendOnFailure( notifier.isSendOnFailure() ); notif.setSendOnError( notifier.isSendOnError() ); notif.setSendOnWarning( notifier.isSendOnWarning() ); notif.setConfiguration( notifier.getConfiguration() ); notif.setType( notifier.getType() ); notif.setFrom( ProjectNotifier.FROM_USER ); ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId ); projectGroup.addNotifier( notif ); try { store.updateProjectGroup( projectGroup ); } catch ( ContinuumStoreException cse ) { throw new ContinuumException( "unable to add notifier to project group", cse ); } return notif; }
public ProjectNotifier addGroupNotifier( int projectGroupId, ProjectNotifier notifier ) throws ContinuumException { ProjectNotifier notif = new ProjectNotifier(); notif.setSendOnSuccess( notifier.isSendOnSuccess() ); notif.setSendOnFailure( notifier.isSendOnFailure() ); notif.setSendOnError( notifier.isSendOnError() ); notif.setSendOnWarning( notifier.isSendOnWarning() ); notif.setSendOnScmFailure( notifier.isSendOnScmFailure() ); notif.setConfiguration( notifier.getConfiguration() ); notif.setType( notifier.getType() ); notif.setFrom( ProjectNotifier.FROM_USER ); ProjectGroup projectGroup = getProjectGroupWithBuildDetails( projectGroupId ); projectGroup.addNotifier( notif ); try { projectGroupDao.updateProjectGroup( projectGroup ); } catch ( ContinuumStoreException cse ) { throw new ContinuumException( "unable to add notifier to project group", cse ); } return notif; }
userNotifier.setType( notifier.getType() );