* @param notifier
* @return
*/
private NotifierSummary generateNotifierSummary( ProjectNotifier notifier, int projectGroupId, Project project )
{
NotifierSummary ns = new NotifierSummary();
ns.setId( notifier.getId() );
ns.setType( notifier.getType() );
ns.setProjectGroupId( projectGroupId );
if ( project != null )
{
ns.setProjectId( project.getId() );
ns.setProjectName( project.getName() );
}
if ( notifier.isFromProject() )
{
ns.setFromProject( true );
}
else
{
ns.setFromProject( false );
}
// Source the recipient
Map configuration = notifier.getConfiguration();
String recipient = "unknown";
if ( ( "mail".equals( notifier.getType() ) ) || ( "msn".equals( notifier.getType() ) ) ||
( "jabber".equals( notifier.getType() ) ) )
{
if ( StringUtils.isNotEmpty( (String) configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD ) ) )
{
recipient = (String) configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD );
}
if ( StringUtils.isNotEmpty( (String) configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) ) )
{
if ( Boolean.parseBoolean( (String) configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) ) )
{
if ( "unknown".equals( recipient ) )
{
recipient = "latest committers";
}
else
{
recipient += ", " + "latest committers";
}
}
}
}
if ( "irc".equals( notifier.getType() ) )
{
recipient = (String) configuration.get( "host" );
if ( configuration.get( "port" ) != null )
{
recipient = recipient + ":" + (String) configuration.get( "port" );
}
recipient = recipient + ":" + (String) configuration.get( "channel" );
}
if ( "wagon".equals( notifier.getType() ) )
{
recipient = (String) configuration.get( "url" );
}
ns.setRecipient( recipient );
// XXX: Hack - just for testing :)
StringBuffer sb = new StringBuffer();
if ( notifier.isSendOnError() )
{
sb.append( "Error" );
}
if ( notifier.isSendOnFailure() )
{
if ( sb.length() > 0 )
{
sb.append( '/' );
}
sb.append( "Failure" );
}
if ( notifier.isSendOnSuccess() )
{
if ( sb.length() > 0 )
{
sb.append( '/' );
}
sb.append( "Success" );
}
if ( notifier.isSendOnWarning() )
{
if ( sb.length() > 0 )
{
sb.append( '/' );
}
sb.append( "Warning" );
}
if ( notifier.isSendOnScmFailure() )
{
if ( sb.length() > 0 )
{
sb.append( '/' );
}
sb.append( "SCM Failure" );
}
ns.setEvents( sb.toString() );
ns.setEnabled( notifier.isEnabled() );
return ns;
}