Notification Type Providers Directory

In order to extend Notification Type definitions, Minyaa introduces a Notification Type Providers Directory.

Its allows you to extend Notification Types by replacing the Notification Types Manager.



Currently, JIRA does not stored Notification Type in Database!

To avoid to develop a new solution with its own Database storage, with new Web interfaces and, surely, have to remove them, when Database storage will be implemented natively by JIRA, Minyaa choose to extend just the existing mechanism based on a XML configuration.

How it is working ?

The default JIRA implementation of NotificationTypeManager (DefaultNotificationTypeManager) is replaced by ProvidedNotificationTypeManager



This ProvidedNotificationTypeManager is able to offer Notification Types provided by NotificationTypeProvider registered into the NotificationTypeProviderDirectory.



To extend Notification Types, you have to register your own Notification Type Provider.

How to built you own Notification Type Provider ?

In your plugin, follow below steps :

  1. Create NotificationTypeProvider as follow

    				
    package com.yourcompany.jira.notification.provider;
    
    import com.minyaa.jira.notification.provider.NotificationTypeProvider;
    
    public class YourNotificationTypeProvider implements NotificationTypeProvider {
    
    	/* Configuration fiel where Notification Type are refrenced */
    	public static String configFile = "com/yourcompany/your/notification-event-types.xml";
    	
    	/** The Notification Type Provider registers itself to the NotificationTypeProviderDirectory */
    	public YourNotificationTypeProvider(NotificationTypeProviderDirectory _directory) {
    		_directory.addNotificationTypeProvider(this);
    	}
    	
    	/** Accessor to the Configuration File */
    	public String getConfigFile() {
    		return configFile;
    	}
    
    	/** Class used by NotificationTypeProviderDirectory the to reference the NotificationTypeProvider */
    	public Class getTypeClass() {
    		return YourNotificationTypeProvider.class;
    	}
    	
    }
    


  2. Create the configuration file com/yourcompany/your/notification-event-types.xml

    				
    <types>
    	<!-- Your Notification Type implementation -->
    	<type id="Your_Notification_Type">
    		<class>com.yourcompany.jira.notification.type.YourNotificationType</class>
    	</type>
    </types>
    


  3. Create your Notification Type class com.yourcompany.jira.notification.type.YourNotificationType ...

    				
    package com.yourcompany.jira.notification.type;
    
    import java.util.List;
    
    import org.ofbiz.core.entity.GenericValue;
    
    import com.atlassian.jira.event.issue.IssueEvent;
    import com.atlassian.jira.issue.Issue;
    import com.atlassian.jira.security.CustomPermissions;
    import com.atlassian.jira.security.JiraAuthenticationContext;
    
    public class TimesheetApprover extends ANotificationType {
    	public static final String ID = "Your_Notification_Type";
    
    	public TimesheetApprover(final JiraAuthenticationContext _jiraAuthenticationContext) {
    		super(_jiraAuthenticationContext);
    	}
    	
    	public List getRecipients(IssueEvent event, GenericValue project) {
    		List users = null;
    		/* Define here how the list of Users are identified ...
    		 */
    		return getNotificationRecipient(users);
    	}
    
    	public String getDisplayName() {
    		return getDisplayName("admin.notification.types.your.notification");
    	}
    
    }
    
  4. Define your NotificationTypeProvider as component in atlassian-plugin.xml :

    				
    <atlassian-plugin key="jira.plugin.yourcompany.notification" name="Your Company Plugin for Notification Types">
    	<plugin-info>
            <description>${pom.description}</description>
            <version>${pom.version}</version>
            <vendor name="${pom.organization.name}" url="${pom.organization.url}"/>
    	</plugin-info>
    	...
    	<component key="YourNotificationTypeProvider" name="YourNotificationTypeProvider" class="com.yourcompany.jira.notification.provider.YourNotificationTypeProvider" />	
    	...
    </atlassian-plugin>
    


Existing Notification Type Provider

Minyaa provides already Notification Type Providers :
Provider Configuration Details
com.minyaa.jira.notification.provider.DefaultNotificationTypeProvider notification-event-types.xml Default JIRA Notification
com.minyaa.jira.notification.provider.TimesheetNotificationTypeProvider com/minyaa/timesheet/notification-event-types.xml Timesheet Notification Types