[Building Sakai] Using the EmailTemplateService

Steve Swinsburg steve.swinsburg at gmail.com
Mon Jan 4 05:48:54 PST 2010


One issue is if a tool/service developer needs to push an updated template out to everyone. At the moment (in Site Manage), the templates are only updated if they don't exist. So they could be changed in the source and redeployed, but never updated (unless they are removed from the db). This is an easy fix for this particular case, whether this be via a flag in sakai.properties to force the update or by checking timestamps or some other property, but it means everyone needs to include the same duplicated code in order to push the updates. 

The UI is fine for local administrators to update the text, but if it needs to be changed globally, its a bit more of a problem - esp between releases of Sakai.

It would be very useful if there was a 'version' property for each template. It would save messing with timestamps and having them correctly formatted. For example, if the version of the local template file is '4' and the db contains version 3, update it so you get the latest changes.

I also think the idea of having a registry of templates added in via Spring, very similar to how the Hibernate mappings work, would be great. Then the whole loading and version checking could be abstracted away from each tool/service and put into the EmailTemplateService itself. An XML schema could be established as well, similar to what the site manage service has at the moment.

cheers,
Steve

On 04/01/2010, at 8:30 PM, Aaron Zeckoski wrote:

> Last modified date is in there already.
> 
> It is possible to store the templates in any form you like (including
> putting them into a properties file) and while having a convenience
> method might be nice I am not sure it adds all that much since the
> main use case was editing the templates via the web interface. The
> initial load is from a file (like properties or XML or whatever) but I
> was expecting people would prefer to edit them via a UI after that
> rather than trying to modify the source files.
> 
> -AZ
> 
> 
> On Mon, Jan 4, 2010 at 8:35 AM, Steve Swinsburg
> <steve.swinsburg at gmail.com> wrote:
>> Thanks gents,
>> 
>> I did notice the parts in site-manage but wasn't sure if that was the current state of how it was to be implemented so thought best to check.
>> 
>> For elegance, what about some wrapper methods that load/update the template for you, given the path of the XML file and some property which says what version it is/last modified date? This is something that would need to be implemented for each tool that uses the ETS so would be a good candidate for an API method in ETS itself.
>> 
>> Also, is it possible to have multiple localised XML files for the one template
>> ie
>> myTemplate.xml
>> myTemplate_en_GB.xml
>> myTemplate_nl.xml
>> 
>> rather than having all of the various localised versions in the one file?
>> 
>> cheers,
>> Steve
>> 
>> 
>> On 04/01/2010, at 6:42 PM, David Horwitz wrote:
>> 
>>> You Might have a look at the Notification manager in site-manage:
>>> 
>>> https://source.sakaiproject.org/svn/site-manage/trunk/site-manage-impl/impl/src/java/org/sakaiproject/sitemanage/impl/ETSUserNotificationProviderImpl.java
>>> 
>>> This loads them from an xml file and saves them. Suggestions to make
>>> this more elegant welcomed :-)
>>> 
>>> D
>>> 
>>> On 01/04/2010 09:37 AM, Aaron Zeckoski wrote:
>>>> Mostly just the javadocs really. :-)
>>>> 
>>>> The simplest way to do this would be to create a spring bean (or use
>>>> an existing one) with an init method and then call
>>>> EmailTemplateService.saveTemplate(EmailTemplate emailTemplate) with
>>>> the content of your template. This will store the template which you
>>>> can then use from then on. You could check the date on the template
>>>> file(s) to see if it had been updated and then update the template(s)
>>>> in the database. There isn't anything to do this for you in the
>>>> service though so you will have to write some code to handle it.
>>>> 
>>>> Hope that helps.
>>>> -AZ
>>>> 
>>>> 
>>>> 
>>>> On Mon, Jan 4, 2010 at 3:55 AM, Steve Swinsburg
>>>> <steve.swinsburg at gmail.com> wrote:
>>>> 
>>>>> Hi all,
>>>>> 
>>>>> Are there any docs on how to use the EmailTemplateService?
>>>>> 
>>>>> For example, I want to be able to define a template and replacement variables for an email that my tool is to send, and then abstract that out into a file somewhere that can be internationalised. Is there some way to register the new templates that I create with the ETS via Spring?
>>>>> 
>>>>> thanks,
>>>>> Steve
>>>>> _______________________________________________
>>>>> sakai-dev mailing list
>>>>> sakai-dev at collab.sakaiproject.org
>>>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>>> 
>>>>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> 
>>> _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>> 
>>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>> 
>> 
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>> 
>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>> 
> 
> 
> 
> -- 
> Aaron Zeckoski (azeckoski (at) vt.edu)
> Senior Research Engineer - CARET - University of Cambridge
> https://twitter.com/azeckoski - http://www.linkedin.com/in/azeckoski
> http://aaronz-sakai.blogspot.com/ - http://tinyurl.com/azprofile

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3823 bytes
Desc: not available
Url : http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100105/d5afab29/attachment.bin 


More information about the sakai-dev mailing list