01: /**********************************************************************************
02: * $URL:https://source.sakaiproject.org/svn/osp/trunk/presentation/tool/src/java/org/theospi/portfolio/presentation/model/VelocityMailMessage.java $
03: * $Id:VelocityMailMessage.java 9134 2006-05-08 20:28:42Z chmaurer@iupui.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.theospi.portfolio.presentation.model;
21:
22: import java.util.Map;
23:
24: import org.apache.velocity.exception.VelocityException;
25: import org.sakaiproject.metaobj.utils.mvc.impl.LocalVelocityConfigurer;
26: import org.springframework.mail.SimpleMailMessage;
27: import org.springframework.ui.velocity.VelocityEngineUtils;
28:
29: public class VelocityMailMessage extends SimpleMailMessage {
30: private String template;
31: private LocalVelocityConfigurer velocityConfigurer;
32:
33: public VelocityMailMessage() {
34: super ();
35: }
36:
37: public VelocityMailMessage(SimpleMailMessage message) {
38: super (message);
39: }
40:
41: public String getTemplate() {
42: return template;
43: }
44:
45: public void setTemplate(String template) {
46: this .template = template;
47: }
48:
49: public void setModel(Map model) throws VelocityException {
50: String result = null;
51: result = VelocityEngineUtils.mergeTemplateIntoString(
52: getVelocityConfigurer().getVelocityEngine(),
53: getTemplate(), model);
54: this .setText(result);
55: }
56:
57: public LocalVelocityConfigurer getVelocityConfigurer() {
58: return velocityConfigurer;
59: }
60:
61: public void setVelocityConfigurer(
62: LocalVelocityConfigurer velocityConfigurer) {
63: this.velocityConfigurer = velocityConfigurer;
64: }
65: }
|