2 * Sone - WebInterface.java - Copyright © 2010–2013 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 static java.util.logging.Logger.getLogger;
21 import static net.pterodactylus.util.template.TemplateParser.parse;
23 import java.io.IOException;
24 import java.io.StringReader;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.Collections;
28 import java.util.HashMap;
29 import java.util.HashSet;
30 import java.util.List;
33 import java.util.UUID;
34 import java.util.concurrent.Executors;
35 import java.util.concurrent.ScheduledExecutorService;
36 import java.util.concurrent.ScheduledFuture;
37 import java.util.concurrent.TimeUnit;
38 import java.util.logging.Level;
39 import java.util.logging.Logger;
41 import net.pterodactylus.sone.core.Core;
42 import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
43 import net.pterodactylus.sone.core.event.ImageInsertFailedEvent;
44 import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
45 import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
46 import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
47 import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
48 import net.pterodactylus.sone.core.event.MarkSoneKnownEvent;
49 import net.pterodactylus.sone.core.event.NewPostFoundEvent;
50 import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
51 import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
52 import net.pterodactylus.sone.core.event.PostRemovedEvent;
53 import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
54 import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
55 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
56 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
57 import net.pterodactylus.sone.core.event.SoneLockedEvent;
58 import net.pterodactylus.sone.core.event.SoneRemovedEvent;
59 import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
60 import net.pterodactylus.sone.core.event.UpdateFoundEvent;
61 import net.pterodactylus.sone.data.Album;
62 import net.pterodactylus.sone.data.Image;
63 import net.pterodactylus.sone.data.Post;
64 import net.pterodactylus.sone.data.PostReply;
65 import net.pterodactylus.sone.data.Profile;
66 import net.pterodactylus.sone.data.Reply;
67 import net.pterodactylus.sone.data.Sone;
68 import net.pterodactylus.sone.freenet.L10nFilter;
69 import net.pterodactylus.sone.freenet.wot.Identity;
70 import net.pterodactylus.sone.freenet.wot.Trust;
71 import net.pterodactylus.sone.main.Loaders;
72 import net.pterodactylus.sone.main.ReparseFilter;
73 import net.pterodactylus.sone.main.SonePlugin;
74 import net.pterodactylus.sone.notify.ListNotification;
75 import net.pterodactylus.sone.template.AlbumAccessor;
76 import net.pterodactylus.sone.template.BuildIdFilter;
77 import net.pterodactylus.sone.template.CollectionAccessor;
78 import net.pterodactylus.sone.template.CssClassNameFilter;
79 import net.pterodactylus.sone.template.HttpRequestAccessor;
80 import net.pterodactylus.sone.template.IdentityAccessor;
81 import net.pterodactylus.sone.template.ImageAccessor;
82 import net.pterodactylus.sone.template.ImageLinkFilter;
83 import net.pterodactylus.sone.template.JavascriptFilter;
84 import net.pterodactylus.sone.template.ListAccessor;
85 import net.pterodactylus.sone.template.ParserFilter;
86 import net.pterodactylus.sone.template.PostAccessor;
87 import net.pterodactylus.sone.template.ProfileAccessor;
88 import net.pterodactylus.sone.template.RenderFilter;
89 import net.pterodactylus.sone.template.ReplyAccessor;
90 import net.pterodactylus.sone.template.ReplyGroupFilter;
91 import net.pterodactylus.sone.template.RequestChangeFilter;
92 import net.pterodactylus.sone.template.SoneAccessor;
93 import net.pterodactylus.sone.template.SubstringFilter;
94 import net.pterodactylus.sone.template.TrustAccessor;
95 import net.pterodactylus.sone.template.UniqueElementFilter;
96 import net.pterodactylus.sone.template.UnknownDateFilter;
97 import net.pterodactylus.sone.text.Part;
98 import net.pterodactylus.sone.text.SonePart;
99 import net.pterodactylus.sone.text.SoneTextParser;
100 import net.pterodactylus.sone.web.ajax.BookmarkAjaxPage;
101 import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
102 import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
103 import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
104 import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
105 import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
106 import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
107 import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
108 import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage;
109 import net.pterodactylus.sone.web.ajax.EditImageAjaxPage;
110 import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
111 import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
112 import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
113 import net.pterodactylus.sone.web.ajax.GetNotificationsAjaxPage;
114 import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
115 import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
116 import net.pterodactylus.sone.web.ajax.GetStatusAjaxPage;
117 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
118 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
119 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
120 import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
121 import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage;
122 import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
123 import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
124 import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage;
125 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
126 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
127 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
128 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
129 import net.pterodactylus.sone.web.page.FreenetRequest;
130 import net.pterodactylus.sone.web.page.PageToadlet;
131 import net.pterodactylus.sone.web.page.PageToadletFactory;
132 import net.pterodactylus.util.notify.Notification;
133 import net.pterodactylus.util.notify.NotificationManager;
134 import net.pterodactylus.util.notify.TemplateNotification;
135 import net.pterodactylus.util.template.CollectionSortFilter;
136 import net.pterodactylus.util.template.ContainsFilter;
137 import net.pterodactylus.util.template.DateFilter;
138 import net.pterodactylus.util.template.FormatFilter;
139 import net.pterodactylus.util.template.HtmlFilter;
140 import net.pterodactylus.util.template.MatchFilter;
141 import net.pterodactylus.util.template.ModFilter;
142 import net.pterodactylus.util.template.PaginationFilter;
143 import net.pterodactylus.util.template.ReflectionAccessor;
144 import net.pterodactylus.util.template.ReplaceFilter;
145 import net.pterodactylus.util.template.StoreFilter;
146 import net.pterodactylus.util.template.Template;
147 import net.pterodactylus.util.template.TemplateContextFactory;
148 import net.pterodactylus.util.template.TemplateProvider;
149 import net.pterodactylus.util.template.XmlFilter;
150 import net.pterodactylus.util.web.RedirectPage;
151 import net.pterodactylus.util.web.TemplatePage;
153 import com.google.common.collect.Collections2;
154 import com.google.common.collect.ImmutableSet;
155 import com.google.common.eventbus.Subscribe;
156 import com.google.inject.Inject;
158 import freenet.clients.http.SessionManager;
159 import freenet.clients.http.SessionManager.Session;
160 import freenet.clients.http.ToadletContainer;
161 import freenet.clients.http.ToadletContext;
162 import freenet.l10n.BaseL10n;
163 import freenet.support.api.HTTPRequest;
166 * Bundles functionality that a web interface of a Freenet plugin needs, e.g.
167 * references to l10n helpers.
169 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
171 public class WebInterface {
174 private static final Logger logger = getLogger(WebInterface.class.getName());
176 /** The loaders for templates, pages, and classpath providers. */
177 private final Loaders loaders;
179 /** The notification manager. */
180 private final NotificationManager notificationManager = new NotificationManager();
182 /** The Sone plugin. */
183 private final SonePlugin sonePlugin;
185 /** The registered toadlets. */
186 private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
188 /** The form password. */
189 private final String formPassword;
191 /** The template context factory. */
192 private final TemplateContextFactory templateContextFactory;
194 /** The Sone text parser. */
195 private final SoneTextParser soneTextParser;
197 /** The parser filter. */
198 private final ParserFilter parserFilter;
199 private final RenderFilter renderFilter;
201 /** The “new Sone” notification. */
202 private final ListNotification<Sone> newSoneNotification;
204 /** The “new post” notification. */
205 private final ListNotification<Post> newPostNotification;
207 /** The “new reply” notification. */
208 private final ListNotification<PostReply> newReplyNotification;
210 /** The invisible “local post” notification. */
211 private final ListNotification<Post> localPostNotification;
213 /** The invisible “local reply” notification. */
214 private final ListNotification<PostReply> localReplyNotification;
216 /** The “you have been mentioned” notification. */
217 private final ListNotification<Post> mentionNotification;
219 /** Notifications for sone inserts. */
220 private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
222 /** Sone locked notification ticker objects. */
223 private final Map<Sone, ScheduledFuture<?>> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap<Sone, ScheduledFuture<?>>());
225 /** The “Sone locked” notification. */
226 private final ListNotification<Sone> lockedSonesNotification;
228 /** The “new version” notification. */
229 private final TemplateNotification newVersionNotification;
231 /** The “inserting images” notification. */
232 private final ListNotification<Image> insertingImagesNotification;
234 /** The “inserted images” notification. */
235 private final ListNotification<Image> insertedImagesNotification;
237 /** The “image insert failed” notification. */
238 private final ListNotification<Image> imageInsertFailedNotification;
240 /** Scheduled executor for time-based notifications. */
241 private final ScheduledExecutorService ticker = Executors.newScheduledThreadPool(1);
244 * Creates a new web interface.
250 public WebInterface(SonePlugin sonePlugin, Loaders loaders) {
251 this.sonePlugin = sonePlugin;
252 this.loaders = loaders;
253 formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
254 soneTextParser = new SoneTextParser(getCore(), getCore(), getCore());
256 templateContextFactory = new TemplateContextFactory();
257 templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
258 templateContextFactory.addAccessor(Collection.class, new CollectionAccessor());
259 templateContextFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
260 templateContextFactory.addAccessor(Post.class, new PostAccessor(getCore()));
261 templateContextFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
262 templateContextFactory.addAccessor(Album.class, new AlbumAccessor());
263 templateContextFactory.addAccessor(Image.class, new ImageAccessor());
264 templateContextFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
265 templateContextFactory.addAccessor(Trust.class, new TrustAccessor());
266 templateContextFactory.addAccessor(HTTPRequest.class, new HttpRequestAccessor());
267 templateContextFactory.addAccessor(Profile.class, new ProfileAccessor(getCore()));
268 templateContextFactory.addAccessor(List.class, new ListAccessor());
269 templateContextFactory.addFilter("date", new DateFilter());
270 templateContextFactory.addFilter("html", new HtmlFilter());
271 templateContextFactory.addFilter("replace", new ReplaceFilter());
272 templateContextFactory.addFilter("store", new StoreFilter());
273 templateContextFactory.addFilter("l10n", new L10nFilter(this));
274 templateContextFactory.addFilter("substring", new SubstringFilter());
275 templateContextFactory.addFilter("xml", new XmlFilter());
276 templateContextFactory.addFilter("change", new RequestChangeFilter());
277 templateContextFactory.addFilter("match", new MatchFilter());
278 templateContextFactory.addFilter("css", new CssClassNameFilter());
279 templateContextFactory.addFilter("js", new JavascriptFilter());
280 templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), soneTextParser));
281 templateContextFactory.addFilter("reparse", new ReparseFilter());
282 templateContextFactory.addFilter("render", renderFilter = new RenderFilter(getCore(), templateContextFactory));
283 templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
284 templateContextFactory.addFilter("format", new FormatFilter());
285 templateContextFactory.addFilter("sort", new CollectionSortFilter());
286 templateContextFactory.addFilter("image-link", new ImageLinkFilter(getCore(), templateContextFactory));
287 templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
288 templateContextFactory.addFilter("in", new ContainsFilter());
289 templateContextFactory.addFilter("unique", new UniqueElementFilter());
290 templateContextFactory.addFilter("mod", new ModFilter());
291 templateContextFactory.addFilter("paginate", new PaginationFilter());
292 templateContextFactory.addFilter("build-id", new BuildIdFilter());
293 templateContextFactory.addProvider(TemplateProvider.TEMPLATE_CONTEXT_PROVIDER);
294 templateContextFactory.addProvider(loaders.getTemplateProvider());
295 templateContextFactory.addTemplateObject("webInterface", this);
296 templateContextFactory.addTemplateObject("formPassword", formPassword);
298 /* create notifications. */
299 Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
300 newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
302 Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
303 newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
305 Template localPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
306 localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);
308 Template newReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
309 newReplyNotification = new ListNotification<PostReply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
311 Template localReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
312 localReplyNotification = new ListNotification<PostReply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);
314 Template mentionNotificationTemplate = loaders.loadTemplate("/templates/notify/mentionNotification.html");
315 mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
317 Template lockedSonesTemplate = loaders.loadTemplate("/templates/notify/lockedSonesNotification.html");
318 lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);
320 Template newVersionTemplate = loaders.loadTemplate("/templates/notify/newVersionNotification.html");
321 newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);
323 Template insertingImagesTemplate = loaders.loadTemplate("/templates/notify/inserting-images-notification.html");
324 insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);
326 Template insertedImagesTemplate = loaders.loadTemplate("/templates/notify/inserted-images-notification.html");
327 insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);
329 Template imageInsertFailedTemplate = loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html");
330 imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
338 * Returns the Sone core used by the Sone plugin.
340 * @return The Sone core
342 public Core getCore() {
343 return sonePlugin.core();
347 * Returns the template context factory of the web interface.
349 * @return The template context factory
351 public TemplateContextFactory getTemplateContextFactory() {
352 return templateContextFactory;
356 * Returns the current session, creating a new session if there is no
359 * @param toadletContenxt
360 * The toadlet context
361 * @return The current session, or {@code null} if there is no current
364 public Session getCurrentSession(ToadletContext toadletContenxt) {
365 return getCurrentSession(toadletContenxt, true);
369 * Returns the current session, creating a new session if there is no
370 * current session and {@code create} is {@code true}.
372 * @param toadletContenxt
373 * The toadlet context
375 * {@code true} to create a new session if there is no current
376 * session, {@code false} otherwise
377 * @return The current session, or {@code null} if there is no current
380 public Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
381 Session session = getSessionManager().useSession(toadletContenxt);
382 if (create && (session == null)) {
383 session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
389 * Returns the currently logged in Sone.
391 * @param toadletContext
392 * The toadlet context
393 * @return The currently logged in Sone, or {@code null} if no Sone is
394 * currently logged in
396 public Sone getCurrentSone(ToadletContext toadletContext) {
397 return getCurrentSone(toadletContext, true);
401 * Returns the currently logged in Sone.
403 * @param toadletContext
404 * The toadlet context
406 * {@code true} to create a new session if no session exists,
407 * {@code false} to not create a new session
408 * @return The currently logged in Sone, or {@code null} if no Sone is
409 * currently logged in
411 public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
412 Collection<Sone> localSones = getCore().getLocalSones();
413 if (localSones.size() == 1) {
414 return localSones.iterator().next();
416 return getCurrentSone(getCurrentSession(toadletContext, create));
420 * Returns the currently logged in Sone.
424 * @return The currently logged in Sone, or {@code null} if no Sone is
425 * currently logged in
427 public Sone getCurrentSone(Session session) {
428 if (session == null) {
431 String soneId = (String) session.getAttribute("Sone.CurrentSone");
432 if (soneId == null) {
435 return getCore().getLocalSone(soneId);
439 * Sets the currently logged in Sone.
441 * @param toadletContext
442 * The toadlet context
444 * The Sone to set as currently logged in
446 public void setCurrentSone(ToadletContext toadletContext, Sone sone) {
447 Session session = getCurrentSession(toadletContext);
449 session.removeAttribute("Sone.CurrentSone");
451 session.setAttribute("Sone.CurrentSone", sone.getId());
456 * Returns the notification manager.
458 * @return The notification manager
460 public NotificationManager getNotifications() {
461 return notificationManager;
465 * Returns the l10n helper of the node.
467 * @return The node’s l10n helper
469 public BaseL10n getL10n() {
470 return sonePlugin.l10n().getBase();
474 * Returns the session manager of the node.
476 * @return The node’s session manager
478 public SessionManager getSessionManager() {
479 return sonePlugin.pluginRespirator().getSessionManager("Sone");
483 * Returns the node’s form password.
485 * @return The form password
487 public String getFormPassword() {
492 * Returns the posts that have been announced as new in the
493 * {@link #newPostNotification}.
495 * @return The new posts
497 public Set<Post> getNewPosts() {
498 return ImmutableSet.<Post> builder().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).build();
502 * Returns the replies that have been announced as new in the
503 * {@link #newReplyNotification}.
505 * @return The new replies
507 public Set<PostReply> getNewReplies() {
508 return ImmutableSet.<PostReply> builder().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).build();
512 * Sets whether the current start of the plugin is the first start. It is
513 * considered a first start if the configuration file does not exist.
516 * {@code true} if no configuration file existed when Sone was
517 * loaded, {@code false} otherwise
519 public void setFirstStart(boolean firstStart) {
521 Template firstStartNotificationTemplate = loaders.loadTemplate("/templates/notify/firstStartNotification.html");
522 Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate);
523 notificationManager.addNotification(firstStartNotification);
528 * Sets whether Sone was started with a fresh configuration file.
531 * {@code true} if Sone was started with a fresh configuration,
532 * {@code false} if the existing configuration could be read
534 public void setNewConfig(boolean newConfig) {
535 if (newConfig && !hasFirstStartNotification()) {
536 Template configNotReadNotificationTemplate = loaders.loadTemplate("/templates/notify/configNotReadNotification.html");
537 Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate);
538 notificationManager.addNotification(configNotReadNotification);
547 * Returns whether the first start notification is currently displayed.
549 * @return {@code true} if the first-start notification is currently
550 * displayed, {@code false} otherwise
552 private boolean hasFirstStartNotification() {
553 return notificationManager.getNotification("first-start-notification") != null;
561 * Starts the web interface and registers all toadlets.
563 public void start() {
566 /* notification templates. */
567 Template startupNotificationTemplate = loaders.loadTemplate("/templates/notify/startupNotification.html");
569 final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
570 notificationManager.addNotification(startupNotification);
572 ticker.schedule(new Runnable() {
576 startupNotification.dismiss();
578 }, 2, TimeUnit.MINUTES);
580 Template wotMissingNotificationTemplate = loaders.loadTemplate("/templates/notify/wotMissingNotification.html");
581 final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
582 ticker.scheduleAtFixedRate(new Runnable() {
585 @SuppressWarnings("synthetic-access")
587 if (getCore().getIdentityManager().isConnected()) {
588 wotMissingNotification.dismiss();
590 notificationManager.addNotification(wotMissingNotification);
594 }, 15, 15, TimeUnit.SECONDS);
598 * Stops the web interface and unregisters all toadlets.
601 unregisterToadlets();
602 ticker.shutdownNow();
610 * Register all toadlets.
612 private void registerToadlets() {
613 Template emptyTemplate = parse(new StringReader(""));
614 Template loginTemplate = loaders.loadTemplate("/templates/login.html");
615 Template indexTemplate = loaders.loadTemplate("/templates/index.html");
616 Template newTemplate = loaders.loadTemplate("/templates/new.html");
617 Template knownSonesTemplate = loaders.loadTemplate("/templates/knownSones.html");
618 Template createSoneTemplate = loaders.loadTemplate("/templates/createSone.html");
619 Template createPostTemplate = loaders.loadTemplate("/templates/createPost.html");
620 Template createReplyTemplate = loaders.loadTemplate("/templates/createReply.html");
621 Template bookmarksTemplate = loaders.loadTemplate("/templates/bookmarks.html");
622 Template searchTemplate = loaders.loadTemplate("/templates/search.html");
623 Template editProfileTemplate = loaders.loadTemplate("/templates/editProfile.html");
624 Template editProfileFieldTemplate = loaders.loadTemplate("/templates/editProfileField.html");
625 Template deleteProfileFieldTemplate = loaders.loadTemplate("/templates/deleteProfileField.html");
626 Template viewSoneTemplate = loaders.loadTemplate("/templates/viewSone.html");
627 Template viewPostTemplate = loaders.loadTemplate("/templates/viewPost.html");
628 Template deletePostTemplate = loaders.loadTemplate("/templates/deletePost.html");
629 Template deleteReplyTemplate = loaders.loadTemplate("/templates/deleteReply.html");
630 Template deleteSoneTemplate = loaders.loadTemplate("/templates/deleteSone.html");
631 Template imageBrowserTemplate = loaders.loadTemplate("/templates/imageBrowser.html");
632 Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
633 Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
634 Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
635 Template noPermissionTemplate = loaders.loadTemplate("/templates/noPermission.html");
636 Template emptyImageTitleTemplate = loaders.loadTemplate("/templates/emptyImageTitle.html");
637 Template emptyAlbumTitleTemplate = loaders.loadTemplate("/templates/emptyAlbumTitle.html");
638 Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
639 Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
640 Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
641 Template invalidTemplate = loaders.loadTemplate("/templates/invalid.html");
642 Template postTemplate = loaders.loadTemplate("/templates/include/viewPost.html");
643 Template replyTemplate = loaders.loadTemplate("/templates/include/viewReply.html");
644 Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
646 PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
647 pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
648 pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
649 pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New"));
650 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
651 pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
652 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
653 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldPage(editProfileFieldTemplate, this)));
654 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this)));
655 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
656 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
657 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
658 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
659 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(emptyTemplate, this)));
660 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(emptyTemplate, this)));
661 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
662 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
663 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(emptyTemplate, this)));
664 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(emptyTemplate, this)));
665 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(emptyTemplate, this)));
666 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(emptyTemplate, this)));
667 pageToadlets.add(pageToadletFactory.createPageToadlet(new ImageBrowserPage(imageBrowserTemplate, this), "ImageBrowser"));
668 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateAlbumPage(createAlbumTemplate, this)));
669 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumPage(emptyTemplate, this)));
670 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this)));
671 pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this)));
672 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this)));
673 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this)));
674 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this)));
675 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this)));
676 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this)));
677 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownPage(emptyTemplate, this)));
678 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkPage(emptyTemplate, this)));
679 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkPage(emptyTemplate, this)));
680 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarksPage(bookmarksTemplate, this), "Bookmarks"));
681 pageToadlets.add(pageToadletFactory.createPageToadlet(new SearchPage(searchTemplate, this)));
682 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
683 pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
684 pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout"));
685 pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
686 pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue"));
687 pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION, SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
688 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
689 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this)));
690 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this)));
691 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
692 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
693 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css")));
694 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("javascript/", "/static/javascript/", "text/javascript")));
695 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("images/", "/static/images/", "image/png")));
696 pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage<FreenetRequest>("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
697 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetImagePage(this)));
698 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
699 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
700 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationsAjaxPage(this)));
701 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this)));
702 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostAjaxPage(this)));
703 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyAjaxPage(this)));
704 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
705 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetPostAjaxPage(this, postTemplate)));
706 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTimesAjaxPage(this)));
707 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownAjaxPage(this)));
708 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
709 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
710 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
711 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
712 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
713 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
714 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumAjaxPage(this, parserFilter, renderFilter)));
715 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter, renderFilter)));
716 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
717 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
718 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
719 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
720 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikeAjaxPage(this)));
721 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetLikesAjaxPage(this)));
722 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkAjaxPage(this)));
723 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkAjaxPage(this)));
724 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldAjaxPage(this)));
725 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldAjaxPage(this)));
726 pageToadlets.add(pageToadletFactory.createPageToadlet(new MoveProfileFieldAjaxPage(this)));
728 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
729 toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin);
730 for (PageToadlet toadlet : pageToadlets) {
731 String menuName = toadlet.getMenuName();
732 if (menuName != null) {
733 toadletContainer.register(toadlet, "Navigation.Menu.Sone.Name", toadlet.path(), true, "Navigation.Menu.Sone.Item." + menuName + ".Name", "Navigation.Menu.Sone.Item." + menuName + ".Tooltip", false, toadlet);
735 toadletContainer.register(toadlet, null, toadlet.path(), true, false);
741 * Unregisters all toadlets.
743 private void unregisterToadlets() {
744 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
745 for (PageToadlet pageToadlet : pageToadlets) {
746 toadletContainer.unregister(pageToadlet);
748 toadletContainer.getPageMaker().removeNavigationCategory("Navigation.Menu.Sone.Name");
752 * Returns all {@link Sone#isLocal() local Sone}s that are referenced by
753 * {@link SonePart}s in the given text (after parsing it using
754 * {@link SoneTextParser}).
758 * @return All mentioned local Sones
760 private Collection<Sone> getMentionedSones(String text) {
761 /* we need no context to find mentioned Sones. */
762 Set<Sone> mentionedSones = new HashSet<Sone>();
764 for (Part part : soneTextParser.parse(null, new StringReader(text))) {
765 if (part instanceof SonePart) {
766 mentionedSones.add(((SonePart) part).getSone());
769 } catch (IOException ioe1) {
770 logger.log(Level.WARNING, String.format("Could not parse post text: %s", text), ioe1);
772 return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
776 * Returns the Sone insert notification for the given Sone. If no
777 * notification for the given Sone exists, a new notification is created and
781 * The Sone to get the insert notification for
782 * @return The Sone insert notification
784 private TemplateNotification getSoneInsertNotification(Sone sone) {
785 synchronized (soneInsertNotifications) {
786 TemplateNotification templateNotification = soneInsertNotifications.get(sone);
787 if (templateNotification == null) {
788 templateNotification = new TemplateNotification(loaders.loadTemplate("/templates/notify/soneInsertNotification.html"));
789 templateNotification.set("insertSone", sone);
790 soneInsertNotifications.put(sone, templateNotification);
792 return templateNotification;
796 private boolean localSoneMentionedInNewPostOrReply(Post post) {
797 if (!post.getSone().isLocal()) {
798 if (!getMentionedSones(post.getText()).isEmpty() && !post.isKnown()) {
802 for (PostReply postReply : getCore().getReplies(post.getId())) {
803 if (postReply.getSone().isLocal()) {
806 if (!getMentionedSones(postReply.getText()).isEmpty() && !postReply.isKnown()) {
818 * Notifies the web interface that a new {@link Sone} was found.
820 * @param newSoneFoundEvent
824 public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
825 newSoneNotification.add(newSoneFoundEvent.sone());
826 if (!hasFirstStartNotification()) {
827 notificationManager.addNotification(newSoneNotification);
832 * Notifies the web interface that a new {@link Post} was found.
834 * @param newPostFoundEvent
838 public void newPostFound(NewPostFoundEvent newPostFoundEvent) {
839 Post post = newPostFoundEvent.post();
840 boolean isLocal = post.getSone().isLocal();
842 localPostNotification.add(post);
844 newPostNotification.add(post);
846 if (!hasFirstStartNotification()) {
847 notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
848 if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
849 mentionNotification.add(post);
850 notificationManager.addNotification(mentionNotification);
853 getCore().markPostKnown(post);
858 * Notifies the web interface that a new {@link PostReply} was found.
860 * @param newPostReplyFoundEvent
864 public void newReplyFound(NewPostReplyFoundEvent newPostReplyFoundEvent) {
865 PostReply reply = newPostReplyFoundEvent.postReply();
866 boolean isLocal = reply.getSone().isLocal();
868 localReplyNotification.add(reply);
870 newReplyNotification.add(reply);
872 if (!hasFirstStartNotification()) {
873 notificationManager.addNotification(isLocal ? localReplyNotification : newReplyNotification);
874 if (reply.getPost().isPresent() && localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
875 mentionNotification.add(reply.getPost().get());
876 notificationManager.addNotification(mentionNotification);
879 getCore().markReplyKnown(reply);
884 * Notifies the web interface that a {@link Sone} was marked as known.
886 * @param markSoneKnownEvent
890 public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
891 newSoneNotification.remove(markSoneKnownEvent.sone());
895 * Notifies the web interface that a {@link Post} was marked as known.
897 * @param markPostKnownEvent
901 public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
902 newPostNotification.remove(markPostKnownEvent.post());
903 localPostNotification.remove(markPostKnownEvent.post());
904 if (!localSoneMentionedInNewPostOrReply(markPostKnownEvent.post())) {
905 mentionNotification.remove(markPostKnownEvent.post());
910 * Notifies the web interface that a {@link PostReply} was marked as known.
912 * @param markPostReplyKnownEvent
916 public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
917 PostReply postReply = markPostReplyKnownEvent.postReply();
918 newReplyNotification.remove(postReply);
919 localReplyNotification.remove(postReply);
920 if (postReply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(postReply.getPost().get())) {
921 mentionNotification.remove(postReply.getPost().get());
926 * Notifies the web interface that a {@link Sone} was removed.
928 * @param soneRemovedEvent
932 public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
933 newSoneNotification.remove(soneRemovedEvent.sone());
937 * Notifies the web interface that a {@link Post} was removed.
939 * @param postRemovedEvent
943 public void postRemoved(PostRemovedEvent postRemovedEvent) {
944 newPostNotification.remove(postRemovedEvent.post());
945 localPostNotification.remove(postRemovedEvent.post());
946 if (!localSoneMentionedInNewPostOrReply(postRemovedEvent.post())) {
947 mentionNotification.remove(postRemovedEvent.post());
952 * Notifies the web interface that a {@link PostReply} was removed.
954 * @param postReplyRemovedEvent
958 public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
959 PostReply reply = postReplyRemovedEvent.postReply();
960 newReplyNotification.remove(reply);
961 localReplyNotification.remove(reply);
962 if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
963 mentionNotification.remove(reply.getPost().get());
968 * Notifies the web interface that a Sone was locked.
970 * @param soneLockedEvent
974 public void soneLocked(SoneLockedEvent soneLockedEvent) {
975 final Sone sone = soneLockedEvent.sone();
976 ScheduledFuture<?> tickerObject = ticker.schedule(new Runnable() {
979 @SuppressWarnings("synthetic-access")
981 lockedSonesNotification.add(sone);
982 notificationManager.addNotification(lockedSonesNotification);
984 }, 5, TimeUnit.MINUTES);
985 lockedSonesTickerObjects.put(sone, tickerObject);
989 * Notifies the web interface that a Sone was unlocked.
991 * @param soneUnlockedEvent
995 public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) {
996 lockedSonesNotification.remove(soneUnlockedEvent.sone());
997 lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()).cancel(false);
1001 * Notifies the web interface that a {@link Sone} is being inserted.
1003 * @param soneInsertingEvent
1007 public void soneInserting(SoneInsertingEvent soneInsertingEvent) {
1008 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone());
1009 soneInsertNotification.set("soneStatus", "inserting");
1010 if (soneInsertingEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1011 notificationManager.addNotification(soneInsertNotification);
1016 * Notifies the web interface that a {@link Sone} was inserted.
1018 * @param soneInsertedEvent
1022 public void soneInserted(SoneInsertedEvent soneInsertedEvent) {
1023 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.sone());
1024 soneInsertNotification.set("soneStatus", "inserted");
1025 soneInsertNotification.set("insertDuration", soneInsertedEvent.insertDuration() / 1000);
1026 if (soneInsertedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1027 notificationManager.addNotification(soneInsertNotification);
1032 * Notifies the web interface that a {@link Sone} insert was aborted.
1034 * @param soneInsertAbortedEvent
1038 public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
1039 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
1040 soneInsertNotification.set("soneStatus", "insert-aborted");
1041 soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
1042 if (soneInsertAbortedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1043 notificationManager.addNotification(soneInsertNotification);
1048 * Notifies the web interface that a new Sone version was found.
1050 * @param updateFoundEvent
1054 public void updateFound(UpdateFoundEvent updateFoundEvent) {
1055 newVersionNotification.getTemplateContext().set("latestVersion", updateFoundEvent.version());
1056 newVersionNotification.getTemplateContext().set("latestEdition", updateFoundEvent.latestEdition());
1057 newVersionNotification.getTemplateContext().set("releaseTime", updateFoundEvent.releaseTime());
1058 notificationManager.addNotification(newVersionNotification);
1062 * Notifies the web interface that an image insert was started
1064 * @param imageInsertStartedEvent
1068 public void imageInsertStarted(ImageInsertStartedEvent imageInsertStartedEvent) {
1069 insertingImagesNotification.add(imageInsertStartedEvent.image());
1070 notificationManager.addNotification(insertingImagesNotification);
1074 * Notifies the web interface that an {@link Image} insert was aborted.
1076 * @param imageInsertAbortedEvent
1080 public void imageInsertAborted(ImageInsertAbortedEvent imageInsertAbortedEvent) {
1081 insertingImagesNotification.remove(imageInsertAbortedEvent.image());
1085 * Notifies the web interface that an {@link Image} insert is finished.
1087 * @param imageInsertFinishedEvent
1091 public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
1092 insertingImagesNotification.remove(imageInsertFinishedEvent.image());
1093 insertedImagesNotification.add(imageInsertFinishedEvent.image());
1094 notificationManager.addNotification(insertedImagesNotification);
1098 * Notifies the web interface that an {@link Image} insert has failed.
1100 * @param imageInsertFailedEvent
1104 public void imageInsertFailed(ImageInsertFailedEvent imageInsertFailedEvent) {
1105 insertingImagesNotification.remove(imageInsertFailedEvent.image());
1106 imageInsertFailedNotification.add(imageInsertFailedEvent.image());
1107 notificationManager.addNotification(imageInsertFailedNotification);