Package com.atlassian.jira.template
Class DefaultMailTemplatesService
java.lang.Object
com.atlassian.jira.template.DefaultMailTemplatesService
- All Implemented Interfaces:
MailTemplatesService
@ParametersAreNonnullByDefault
public class DefaultMailTemplatesService
extends Object
implements MailTemplatesService
A default MailTemplateService implementation which is designed to work with files and directories in Jira Shared Home
- Since:
- v8.14
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultMailTemplatesService
(FileStores fileStores, GlobalPermissionManager permissionManager, JiraAuthenticationContext authenticationContext, I18nHelper.BeanFactory i18nFactory, CachingJiraHomeTemplateContentLoader cachingTemplateLoader, EmailVelocityTemplatingEngine templatingEngine, com.atlassian.beehive.ClusterLockService clusterLockService, TemplateValidatorService templateValidatorService, JiraHomeTemplatesRevertService jiraHomeTemplatesRevertService, com.atlassian.event.api.EventPublisher eventPublisher) -
Method Summary
Modifier and TypeMethodDescriptionIf the temporary folder with email templates is present, it will replace the production templates with temporary onesprotected void
copyInputStreamToFile
(@NotNull InputStream inputStream, @NotNull File file) protected void
deleteDirectory
(@NotNull File directory) protected void
deleteIfExists
(@NotNull Path path) Protected methods created to isolate the static functions calls Helps with testingReturns a zip file of the templates folder used for single notifications email.protected String
protected String
protected void
moveDirectory
(@NotNull File srcDir, @NotNull File destDir) protected File
protected File
newJiraFile
(String templatesFileName) protected void
quietlyDeleteDirectory
(@NotNull File directory) protected void
quietlyDeleteIfExists
(@NotNull Path path) Replaces all currently used templates (stored in Shared Jira Home) with default templates.protected void
uploadEmailTemplates
(InputStream templatesStream) Saves a stream to disk and unzips it's content to the temporary templates folder.protected void
-
Field Details
-
TEMPLATES
- See Also:
-
EMAIL_DIR
- See Also:
-
EMAIL_BATCH_DIR
- See Also:
-
IMAGES_DIR
- See Also:
-
TEMP_SUFFIX
- See Also:
-
-
Constructor Details
-
DefaultMailTemplatesService
public DefaultMailTemplatesService(FileStores fileStores, GlobalPermissionManager permissionManager, JiraAuthenticationContext authenticationContext, I18nHelper.BeanFactory i18nFactory, CachingJiraHomeTemplateContentLoader cachingTemplateLoader, EmailVelocityTemplatingEngine templatingEngine, com.atlassian.beehive.ClusterLockService clusterLockService, TemplateValidatorService templateValidatorService, JiraHomeTemplatesRevertService jiraHomeTemplatesRevertService, com.atlassian.event.api.EventPublisher eventPublisher)
-
-
Method Details
-
uploadEmailTemplates
Description copied from interface:MailTemplatesService
Saves a stream to disk and unzips it's content to the temporary templates folder. Then performs validation to check existence of root templates.- Specified by:
uploadEmailTemplates
in interfaceMailTemplatesService
- Returns:
- Valid ServiceOutcome when templates were unzipped and all root files exists Invalid ServiceOutcome with errors otherwise
-
applyEmailTemplates
Description copied from interface:MailTemplatesService
If the temporary folder with email templates is present, it will replace the production templates with temporary ones- Specified by:
applyEmailTemplates
in interfaceMailTemplatesService
- Returns:
- Valid ServiceOutcome when templates replaced Invalid ServiceOutcome with errors otherwise
-
getEmailTemplatesZip
Description copied from interface:MailTemplatesService
Returns a zip file of the templates folder used for single notifications email.- Specified by:
getEmailTemplatesZip
in interfaceMailTemplatesService
- Returns:
- Zipped file of templates folder.
-
revertEmailTemplatesToDefault
Description copied from interface:MailTemplatesService
Replaces all currently used templates (stored in Shared Jira Home) with default templates. If templates were modified then all changes will be overridden.- Specified by:
revertEmailTemplatesToDefault
in interfaceMailTemplatesService
- Returns:
- Valid ServiceOutcome when templates replaced Invalid ServiceOutcome with errors otherwise
-
getLocalizedErrorForUpload
-
getLocalizedErrorForLockRefused
-
deleteIfExists
Protected methods created to isolate the static functions calls Helps with testing- Throws:
IOException
-
newJiraFile
-
zipFolder
- Throws:
IOException
-
quietlyDeleteIfExists
-
copyInputStreamToFile
protected void copyInputStreamToFile(@NotNull @NotNull InputStream inputStream, @NotNull @NotNull File file) throws IOException - Throws:
IOException
-
unzip
- Throws:
IOException
-
deleteDirectory
- Throws:
IOException
-
quietlyDeleteDirectory
-
moveDirectory
protected void moveDirectory(@NotNull @NotNull File srcDir, @NotNull @NotNull File destDir) throws IOException - Throws:
IOException
-
newFile
-