class AcmFilesystemMailTemplateConfigurationService implements AcmMailTemplateConfigurationService {

    @Override
    public String getTemplate(String templateName) throws AcmEmailConfigurationException
    {
        File templateFolder = getTemplateFolder();
        File templateFile = new File(templateFolder, templateName);
        Lock readLock = lock.readLock();
        try
        {
            readLock.lock();
            if (!templateFile.exists())
            {
                log.warn("Email template {} does not exist.", templateName);
                throw new AcmEmailConfigurationIOException(String.format("Email template %s does not exist.", templateName));
            }
            return FileUtils.readFileToString(templateFile, "UTF-8");
        }
        catch (IOException e)
        {
            log.warn("Error while reading contents of {} email template.", templateName, e);
            throw new AcmEmailConfigurationIOException(String.format("Error while reading contents of %s email template.", templateName),
                    e);
        }
        finally
        {
            readLock.unlock();
        }
    }

}