In order to extend Mail Template definitions, Minyaa introduces a Template Providers Directory.
Its allows you to extend Mail Templates by replacing the Template Manager.
Currently, JIRA does not stored Mail Template 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.
The default JIRA implementation of TemplateManager (DefaultTemplateManager) is replaced by ProvidedTemplateManager
This ProvidedTemplateManager is able to offer Mail Templates provided by TemplateProvider registered into the TemplateProviderDirectory.
To extend Mail Template, you have to register your own Template Provider.
In your plugin, follow below steps :
package com.yourcompany.jira.template.provider; import com.minyaa.jira.template.provider.TemplateProvider; public class YourTemplateProvider implements TemplateProvider { /* Configuration fiel where template are refrenced */ public static String configFile = "com/yourcompany/your/email-template-id-mappings.xml"; /** The Template Provider registers itself to the TemplateProviderDirectory */ public YourTemplateProvider(TemplateProviderDirectory _directory) { _directory.addTemplateProvider(this); } /** Accessor to the Configuration File */ public String getConfigFile() { return configFile; } /** Class used by TemplateProviderDirectory the to reference the TemplateProvider */ public Class getTypeClass() { return YourTemplateProvider.class; } /** Root Folder where the Mail Template are stored */ public String getTemplateRootFolder() { return "com/yourcompany/your/templates/"; } }
<!-- this file should be updated in synch with upgrade-system-event-types.xml --> <templatemappings> <templatemapping id="100000"> <name>Your 1st Mail Template</name> <template>MailTemplate1.vm</template> <templatetype>issueevent</templatetype> </templatemapping> <templatemapping id="100001"> <name>Your 2nd Mail Template</name> <template>MailTemplate2.vm</template> <templatetype>issueevent</templatetype> </templatemapping> </templatemappings>
<atlassian-plugin key="jira.plugin.yourcompany.mail" name="Your Company Plugin for Mail Template"> <plugin-info> <description>${pom.description}</description> <version>${pom.version}</version> <vendor name="${pom.organization.name}" url="${pom.organization.url}"/> </plugin-info> ... <component key="YourTemplateProvider" name="YourTemplateProvider" class="com.yourcompany.jira.template.provider.YourTemplateProvider" /> ... </atlassian-plugin>
Provider | Configuration | Details |
---|---|---|
com.minyaa.jira.template.provider.DefaultTemplateProvider | email-template-id-mappings.xml | Default JIRA Template |
com.minyaa.jira.template.provider.TimesheetTemplateProvider | com/minyaa/timesheet/email-template-id-mappings.xml | Timesheet Notification Templates |