2 * FreenetSone - WebInterface.java - Copyright © 2010 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.web;
20 import java.io.InputStream;
21 import java.io.InputStreamReader;
22 import java.io.Reader;
23 import java.io.UnsupportedEncodingException;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.HashSet;
27 import java.util.List;
29 import java.util.UUID;
30 import java.util.logging.Level;
31 import java.util.logging.Logger;
33 import net.pterodactylus.sone.core.Core;
34 import net.pterodactylus.sone.core.CoreListener;
35 import net.pterodactylus.sone.data.Post;
36 import net.pterodactylus.sone.data.Reply;
37 import net.pterodactylus.sone.data.Sone;
38 import net.pterodactylus.sone.freenet.L10nFilter;
39 import net.pterodactylus.sone.freenet.wot.Identity;
40 import net.pterodactylus.sone.main.SonePlugin;
41 import net.pterodactylus.sone.notify.ListNotification;
42 import net.pterodactylus.sone.template.CollectionAccessor;
43 import net.pterodactylus.sone.template.CssClassNameFilter;
44 import net.pterodactylus.sone.template.GetPagePlugin;
45 import net.pterodactylus.sone.template.IdentityAccessor;
46 import net.pterodactylus.sone.template.NotificationManagerAccessor;
47 import net.pterodactylus.sone.template.PostAccessor;
48 import net.pterodactylus.sone.template.ReplyAccessor;
49 import net.pterodactylus.sone.template.RequestChangeFilter;
50 import net.pterodactylus.sone.template.SoneAccessor;
51 import net.pterodactylus.sone.template.SubstringFilter;
52 import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
53 import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
54 import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
55 import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
56 import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
57 import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
58 import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
59 import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
60 import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
61 import net.pterodactylus.sone.web.ajax.GetStatusAjaxPage;
62 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
63 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
64 import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
65 import net.pterodactylus.sone.web.ajax.MarkPostAsKnownPage;
66 import net.pterodactylus.sone.web.ajax.MarkReplyAsKnownPage;
67 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
68 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
69 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
70 import net.pterodactylus.sone.web.page.PageToadlet;
71 import net.pterodactylus.sone.web.page.PageToadletFactory;
72 import net.pterodactylus.sone.web.page.StaticPage;
73 import net.pterodactylus.util.logging.Logging;
74 import net.pterodactylus.util.notify.NotificationManager;
75 import net.pterodactylus.util.notify.TemplateNotification;
76 import net.pterodactylus.util.template.DateFilter;
77 import net.pterodactylus.util.template.DefaultTemplateFactory;
78 import net.pterodactylus.util.template.MatchFilter;
79 import net.pterodactylus.util.template.PaginationPlugin;
80 import net.pterodactylus.util.template.ReflectionAccessor;
81 import net.pterodactylus.util.template.Template;
82 import net.pterodactylus.util.template.TemplateException;
83 import net.pterodactylus.util.template.TemplateFactory;
84 import net.pterodactylus.util.template.TemplateProvider;
85 import net.pterodactylus.util.template.XmlFilter;
86 import net.pterodactylus.util.thread.Ticker;
87 import freenet.clients.http.SessionManager;
88 import freenet.clients.http.SessionManager.Session;
89 import freenet.clients.http.ToadletContainer;
90 import freenet.clients.http.ToadletContext;
91 import freenet.l10n.BaseL10n;
94 * Bundles functionality that a web interface of a Freenet plugin needs, e.g.
95 * references to l10n helpers.
97 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
99 public class WebInterface implements CoreListener {
102 private static final Logger logger = Logging.getLogger(WebInterface.class);
104 /** The notification manager. */
105 private final NotificationManager notificationManager = new NotificationManager();
107 /** The Sone plugin. */
108 private final SonePlugin sonePlugin;
110 /** The registered toadlets. */
111 private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
113 /** The form password. */
114 private final String formPassword;
116 /** The template factory. */
117 private DefaultTemplateFactory templateFactory;
119 /** The “new Sone” notification. */
120 private final ListNotification<Sone> newSoneNotification;
122 /** The “new post” notification. */
123 private final ListNotification<Post> newPostNotification;
125 /** The “new reply” notification. */
126 private final ListNotification<Reply> newReplyNotification;
128 /** The “rescuing Sone” notification. */
129 private final ListNotification<Sone> rescuingSonesNotification;
131 /** The “Sone rescued” notification. */
132 private final ListNotification<Sone> sonesRescuedNotification;
135 * Creates a new web interface.
140 public WebInterface(SonePlugin sonePlugin) {
141 this.sonePlugin = sonePlugin;
142 formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
144 templateFactory = new DefaultTemplateFactory();
145 templateFactory.addAccessor(Object.class, new ReflectionAccessor());
146 templateFactory.addAccessor(Collection.class, new CollectionAccessor());
147 templateFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
148 templateFactory.addAccessor(Post.class, new PostAccessor(getCore(), templateFactory));
149 templateFactory.addAccessor(Reply.class, new ReplyAccessor(getCore(), templateFactory));
150 templateFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
151 templateFactory.addAccessor(NotificationManager.class, new NotificationManagerAccessor());
152 templateFactory.addFilter("date", new DateFilter());
153 templateFactory.addFilter("l10n", new L10nFilter(getL10n()));
154 templateFactory.addFilter("substring", new SubstringFilter());
155 templateFactory.addFilter("xml", new XmlFilter());
156 templateFactory.addFilter("change", new RequestChangeFilter());
157 templateFactory.addFilter("match", new MatchFilter());
158 templateFactory.addFilter("css", new CssClassNameFilter());
159 templateFactory.addPlugin("getpage", new GetPagePlugin());
160 templateFactory.addPlugin("paginate", new PaginationPlugin());
161 templateFactory.setTemplateProvider(new ClassPathTemplateProvider(templateFactory));
162 templateFactory.addTemplateObject("formPassword", formPassword);
164 /* create notifications. */
165 Template newSoneNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newSoneNotification.html"));
166 newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate);
168 Template newPostNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newPostNotification.html"));
169 newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate);
171 Template newReplyNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/newReplyNotification.html"));
172 newReplyNotification = new ListNotification<Reply>("new-replies-notification", "replies", newReplyNotificationTemplate);
174 Template rescuingSonesTemplate = templateFactory.createTemplate(createReader("/templates/notify/rescuingSonesNotification.html"));
175 rescuingSonesNotification = new ListNotification<Sone>("sones-being-rescued-notification", "sones", rescuingSonesTemplate);
177 Template sonesRescuedTemplate = templateFactory.createTemplate(createReader("/templates/notify/sonesRescuedNotification.html"));
178 sonesRescuedNotification = new ListNotification<Sone>("sones-rescued-notification", "sones", sonesRescuedTemplate);
186 * Returns the Sone core used by the Sone plugin.
188 * @return The Sone core
190 public Core getCore() {
191 return sonePlugin.core();
195 * Returns the current session, creating a new session if there is no
198 * @param toadletContenxt
199 * The toadlet context
200 * @return The current session, or {@code null} if there is no current
203 public Session getCurrentSession(ToadletContext toadletContenxt) {
204 return getCurrentSession(toadletContenxt, true);
208 * Returns the current session, creating a new session if there is no
209 * current session and {@code create} is {@code true}.
211 * @param toadletContenxt
212 * The toadlet context
214 * {@code true} to create a new session if there is no current
215 * session, {@code false} otherwise
216 * @return The current session, or {@code null} if there is no current
219 public Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
220 Session session = getSessionManager().useSession(toadletContenxt);
221 if (create && (session == null)) {
222 session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
228 * Returns the currently logged in Sone.
230 * @param toadletContext
231 * The toadlet context
232 * @return The currently logged in Sone, or {@code null} if no Sone is
233 * currently logged in
235 public Sone getCurrentSone(ToadletContext toadletContext) {
236 return getCurrentSone(getCurrentSession(toadletContext));
240 * Returns the currently logged in Sone.
244 * @return The currently logged in Sone, or {@code null} if no Sone is
245 * currently logged in
247 public Sone getCurrentSone(Session session) {
248 if (session == null) {
251 String soneId = (String) session.getAttribute("Sone.CurrentSone");
252 if (soneId == null) {
255 return getCore().getLocalSone(soneId, false);
259 * Sets the currently logged in Sone.
261 * @param toadletContext
262 * The toadlet context
264 * The Sone to set as currently logged in
266 public void setCurrentSone(ToadletContext toadletContext, Sone sone) {
267 Session session = getCurrentSession(toadletContext);
269 session.removeAttribute("Sone.CurrentSone");
271 session.setAttribute("Sone.CurrentSone", sone.getId());
276 * Returns the notification manager.
278 * @return The notification manager
280 public NotificationManager getNotifications() {
281 return notificationManager;
285 * Returns the l10n helper of the node.
287 * @return The node’s l10n helper
289 public BaseL10n getL10n() {
290 return sonePlugin.l10n().getBase();
294 * Returns the session manager of the node.
296 * @return The node’s session manager
298 public SessionManager getSessionManager() {
299 return sonePlugin.pluginRespirator().getSessionManager("Sone");
303 * Returns the node’s form password.
305 * @return The form password
307 public String getFormPassword() {
312 * Returns the posts that have been announced as new in the
313 * {@link #newPostNotification}.
315 * @return The new posts
317 public Set<Post> getNewPosts() {
318 return new HashSet<Post>(newPostNotification.getElements());
322 * Returns the replies that have been announced as new in the
323 * {@link #newReplyNotification}.
325 * @return The new replies
327 public Set<Reply> getNewReplies() {
328 return new HashSet<Reply>(newReplyNotification.getElements());
336 * Starts the web interface and registers all toadlets.
338 public void start() {
341 /* notification templates. */
342 Template startupNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/startupNotification.html"));
344 final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
345 notificationManager.addNotification(startupNotification);
347 Ticker.getInstance().registerEvent(System.currentTimeMillis() + (120 * 1000), new Runnable() {
351 startupNotification.dismiss();
353 }, "Sone Startup Notification Remover");
355 Template wotMissingNotificationTemplate = templateFactory.createTemplate(createReader("/templates/notify/wotMissingNotification.html"));
356 final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
357 Ticker.getInstance().registerEvent(System.currentTimeMillis() + (15 * 1000), new Runnable() {
360 @SuppressWarnings("synthetic-access")
362 if (getCore().getIdentityManager().isConnected()) {
363 wotMissingNotification.dismiss();
365 notificationManager.addNotification(wotMissingNotification);
367 Ticker.getInstance().registerEvent(System.currentTimeMillis() + (15 * 1000), this, "Sone WoT Connector Checker");
370 }, "Sone WoT Connector Checker");
374 * Stops the web interface and unregisters all toadlets.
377 unregisterToadlets();
378 Ticker.getInstance().stop();
386 * Register all toadlets.
388 private void registerToadlets() {
389 Template loginTemplate = templateFactory.createTemplate(createReader("/templates/login.html"));
390 Template indexTemplate = templateFactory.createTemplate(createReader("/templates/index.html"));
391 Template knownSonesTemplate = templateFactory.createTemplate(createReader("/templates/knownSones.html"));
392 Template createSoneTemplate = templateFactory.createTemplate(createReader("/templates/createSone.html"));
393 Template createPostTemplate = templateFactory.createTemplate(createReader("/templates/createPost.html"));
394 Template createReplyTemplate = templateFactory.createTemplate(createReader("/templates/createReply.html"));
395 Template editProfileTemplate = templateFactory.createTemplate(createReader("/templates/editProfile.html"));
396 Template viewSoneTemplate = templateFactory.createTemplate(createReader("/templates/viewSone.html"));
397 Template viewPostTemplate = templateFactory.createTemplate(createReader("/templates/viewPost.html"));
398 Template likePostTemplate = templateFactory.createTemplate(createReader("/templates/like.html"));
399 Template unlikePostTemplate = templateFactory.createTemplate(createReader("/templates/unlike.html"));
400 Template deletePostTemplate = templateFactory.createTemplate(createReader("/templates/deletePost.html"));
401 Template deleteReplyTemplate = templateFactory.createTemplate(createReader("/templates/deleteReply.html"));
402 Template lockSoneTemplate = templateFactory.createTemplate(createReader("/templates/lockSone.html"));
403 Template unlockSoneTemplate = templateFactory.createTemplate(createReader("/templates/unlockSone.html"));
404 Template followSoneTemplate = templateFactory.createTemplate(createReader("/templates/followSone.html"));
405 Template unfollowSoneTemplate = templateFactory.createTemplate(createReader("/templates/unfollowSone.html"));
406 Template deleteSoneTemplate = templateFactory.createTemplate(createReader("/templates/deleteSone.html"));
407 Template noPermissionTemplate = templateFactory.createTemplate(createReader("/templates/noPermission.html"));
408 Template dismissNotificationTemplate = templateFactory.createTemplate(createReader("/templates/dismissNotification.html"));
409 Template logoutTemplate = templateFactory.createTemplate(createReader("/templates/logout.html"));
410 Template optionsTemplate = templateFactory.createTemplate(createReader("/templates/options.html"));
411 Template aboutTemplate = templateFactory.createTemplate(createReader("/templates/about.html"));
412 Template postTemplate = templateFactory.createTemplate(createReader("/templates/include/viewPost.html"));
413 Template replyTemplate = templateFactory.createTemplate(createReader("/templates/include/viewReply.html"));
415 PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
416 pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
417 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
418 pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
419 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
420 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
421 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
422 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
423 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
424 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(likePostTemplate, this)));
425 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(unlikePostTemplate, this)));
426 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
427 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
428 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(lockSoneTemplate, this)));
429 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(unlockSoneTemplate, this)));
430 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(followSoneTemplate, this)));
431 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(unfollowSoneTemplate, this)));
432 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
433 pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
434 pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(logoutTemplate, this), "Logout"));
435 pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
436 pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION), "About"));
437 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
438 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(dismissNotificationTemplate, this)));
439 pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css")));
440 pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("javascript/", "/static/javascript/", "text/javascript")));
441 pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("images/", "/static/images/", "image/png")));
442 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
443 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
444 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this)));
445 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostAjaxPage(this)));
446 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyAjaxPage(this)));
447 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
448 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetPostAjaxPage(this, postTemplate)));
449 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkPostAsKnownPage(this)));
450 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkReplyAsKnownPage(this)));
451 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
452 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
453 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
454 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
455 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
456 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
457 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
458 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikeAjaxPage(this)));
459 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetLikesAjaxPage(this)));
461 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
462 toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Name", "Navigation.Menu.Tooltip", sonePlugin);
463 for (PageToadlet toadlet : pageToadlets) {
464 String menuName = toadlet.getMenuName();
465 if (menuName != null) {
466 toadletContainer.register(toadlet, "Navigation.Menu.Name", toadlet.path(), true, "Navigation.Menu.Item." + menuName + ".Name", "Navigation.Menu.Item." + menuName + ".Tooltip", false, toadlet);
468 toadletContainer.register(toadlet, null, toadlet.path(), true, false);
474 * Unregisters all toadlets.
476 private void unregisterToadlets() {
477 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
478 for (PageToadlet pageToadlet : pageToadlets) {
479 toadletContainer.unregister(pageToadlet);
481 toadletContainer.getPageMaker().removeNavigationCategory("Navigation.Menu.Name");
485 * Creates a {@link Reader} from the {@link InputStream} for the resource
486 * with the given name.
488 * @param resourceName
489 * The name of the resource
490 * @return A {@link Reader} for the resource
492 private Reader createReader(String resourceName) {
494 return new InputStreamReader(getClass().getResourceAsStream(resourceName), "UTF-8");
495 } catch (UnsupportedEncodingException uee1) {
501 // CORELISTENER METHODS
508 public void rescuingSone(Sone sone) {
509 rescuingSonesNotification.add(sone);
510 notificationManager.addNotification(rescuingSonesNotification);
517 public void rescuedSone(Sone sone) {
518 rescuingSonesNotification.remove(sone);
519 sonesRescuedNotification.add(sone);
520 notificationManager.addNotification(sonesRescuedNotification);
527 public void newSoneFound(Sone sone) {
528 newSoneNotification.add(sone);
529 notificationManager.addNotification(newSoneNotification);
536 public void newPostFound(Post post) {
537 newPostNotification.add(post);
538 notificationManager.addNotification(newPostNotification);
545 public void newReplyFound(Reply reply) {
546 if (reply.getPost().getSone() == null) {
549 newReplyNotification.add(reply);
550 notificationManager.addNotification(newReplyNotification);
557 public void markSoneKnown(Sone sone) {
558 newSoneNotification.remove(sone);
565 public void markPostKnown(Post post) {
566 newPostNotification.remove(post);
573 public void markReplyKnown(Reply reply) {
574 newReplyNotification.remove(reply);
581 public void postRemoved(Post post) {
589 public void replyRemoved(Reply reply) {
594 * Template provider implementation that uses
595 * {@link WebInterface#createReader(String)} to load templates for
598 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
600 private class ClassPathTemplateProvider implements TemplateProvider {
602 /** The template factory. */
603 @SuppressWarnings("hiding")
604 private final TemplateFactory templateFactory;
607 * Creates a new template provider that locates templates on the
610 * @param templateFactory
611 * The template factory to create the templates
613 public ClassPathTemplateProvider(TemplateFactory templateFactory) {
614 this.templateFactory = templateFactory;
621 @SuppressWarnings("synthetic-access")
622 public Template getTemplate(String templateName) {
623 Reader templateReader = createReader("/templates/" + templateName);
624 if (templateReader == null) {
627 Template template = templateFactory.createTemplate(templateReader);
630 } catch (TemplateException te1) {
631 logger.log(Level.WARNING, "Could not parse template “" + templateName + "” for inclusion!", te1);