class AcmFilesystemMailTemplateConfigurationService implements AcmMailTemplateConfigurationService {

    @Override
    public void updateEmailTemplate(EmailTemplateConfiguration templateData, MultipartFile template) throws AcmEmailConfigurationException
    {

        File templateFolder = getTemplateFolder();

        List<EmailTemplateConfiguration> configurations = getTemplateConfigurations(templateData);

        Lock writeLock = lock.writeLock();
        writeLock.lock();
        try (OutputStream os = getTemplateResourceOutputStream())
        {
            String configurationsString = getObjectConverter().getJsonMarshaller().marshal(configurations);
            if (configurationsString == null)
            {
                log.warn("Error while serializing email templates configuration to {} file.", templateConfigurations.getDescription(),
                        null);
                throw new AcmEmailConfigurationJsonException(
                        String.format("Error while serializing email templates configuration to %s file.",
                                templateConfigurations.getDescription()),
                        null);
            }
            os.write(configurationsString.getBytes(StandardCharsets.UTF_8));
            if (template != null)
            {
                File templateFile = new File(templateFolder, templateData.getTemplateName());
                template.transferTo(templateFile);
            }
        }
        catch (IOException e)
        {
            log.warn("Error while updating email template configuration for configuration with {} value for templateName.",
                    templateData.getTemplateName(), e);
            throw new AcmEmailConfigurationIOException(
                    String.format("Error while updating email template configuration for configuration with %s value for templateName.",
                            templateData.getTemplateName()),
                    e);
        }
        finally
        {
            writeLock.unlock();
        }

    }

}