2 * Sone - WebInterface.java - Copyright © 2010–2016 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 com.google.common.collect.FluentIterable.from;
21 import static java.util.logging.Logger.getLogger;
22 import static net.pterodactylus.util.template.TemplateParser.parse;
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.Logger;
39 import javax.annotation.Nonnull;
40 import javax.annotation.Nullable;
42 import net.pterodactylus.sone.core.Core;
43 import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
44 import net.pterodactylus.sone.core.event.ImageInsertFailedEvent;
45 import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
46 import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
47 import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
48 import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
49 import net.pterodactylus.sone.core.event.MarkSoneKnownEvent;
50 import net.pterodactylus.sone.core.event.NewPostFoundEvent;
51 import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
52 import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
53 import net.pterodactylus.sone.core.event.PostRemovedEvent;
54 import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
55 import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
56 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
57 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
58 import net.pterodactylus.sone.core.event.SoneLockedEvent;
59 import net.pterodactylus.sone.core.event.SoneRemovedEvent;
60 import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
61 import net.pterodactylus.sone.core.event.UpdateFoundEvent;
62 import net.pterodactylus.sone.data.Album;
63 import net.pterodactylus.sone.data.Image;
64 import net.pterodactylus.sone.data.Post;
65 import net.pterodactylus.sone.data.PostReply;
66 import net.pterodactylus.sone.data.Profile;
67 import net.pterodactylus.sone.data.Reply;
68 import net.pterodactylus.sone.data.Sone;
69 import net.pterodactylus.sone.freenet.L10nFilter;
70 import net.pterodactylus.sone.freenet.wot.Identity;
71 import net.pterodactylus.sone.freenet.wot.Trust;
72 import net.pterodactylus.sone.main.Loaders;
73 import net.pterodactylus.sone.main.ReparseFilter;
74 import net.pterodactylus.sone.main.SonePlugin;
75 import net.pterodactylus.sone.notify.ListNotification;
76 import net.pterodactylus.sone.notify.ListNotificationFilter;
77 import net.pterodactylus.sone.notify.PostVisibilityFilter;
78 import net.pterodactylus.sone.notify.ReplyVisibilityFilter;
79 import net.pterodactylus.sone.template.AlbumAccessor;
80 import net.pterodactylus.sone.template.CollectionAccessor;
81 import net.pterodactylus.sone.template.CssClassNameFilter;
82 import net.pterodactylus.sone.template.HttpRequestAccessor;
83 import net.pterodactylus.sone.template.IdentityAccessor;
84 import net.pterodactylus.sone.template.ImageAccessor;
85 import net.pterodactylus.sone.template.ImageLinkFilter;
86 import net.pterodactylus.sone.template.JavascriptFilter;
87 import net.pterodactylus.sone.template.ParserFilter;
88 import net.pterodactylus.sone.template.PostAccessor;
89 import net.pterodactylus.sone.template.ProfileAccessor;
90 import net.pterodactylus.sone.template.ReplyAccessor;
91 import net.pterodactylus.sone.template.ReplyGroupFilter;
92 import net.pterodactylus.sone.template.RequestChangeFilter;
93 import net.pterodactylus.sone.template.SoneAccessor;
94 import net.pterodactylus.sone.template.SubstringFilter;
95 import net.pterodactylus.sone.template.TrustAccessor;
96 import net.pterodactylus.sone.template.UniqueElementFilter;
97 import net.pterodactylus.sone.template.UnknownDateFilter;
98 import net.pterodactylus.sone.text.Part;
99 import net.pterodactylus.sone.text.SonePart;
100 import net.pterodactylus.sone.text.SoneTextParser;
101 import net.pterodactylus.sone.web.ajax.BookmarkAjaxPage;
102 import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
103 import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
104 import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
105 import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
106 import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
107 import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
108 import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
109 import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage;
110 import net.pterodactylus.sone.web.ajax.EditImageAjaxPage;
111 import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
112 import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
113 import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
114 import net.pterodactylus.sone.web.ajax.GetNotificationsAjaxPage;
115 import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
116 import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
117 import net.pterodactylus.sone.web.ajax.GetStatusAjaxPage;
118 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
119 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
120 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
121 import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
122 import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage;
123 import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
124 import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
125 import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage;
126 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
127 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
128 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
129 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
130 import net.pterodactylus.sone.web.page.FreenetRequest;
131 import net.pterodactylus.sone.web.page.PageToadlet;
132 import net.pterodactylus.sone.web.page.PageToadletFactory;
133 import net.pterodactylus.util.notify.Notification;
134 import net.pterodactylus.util.notify.NotificationManager;
135 import net.pterodactylus.util.notify.TemplateNotification;
136 import net.pterodactylus.util.template.CollectionSortFilter;
137 import net.pterodactylus.util.template.ContainsFilter;
138 import net.pterodactylus.util.template.DateFilter;
139 import net.pterodactylus.util.template.FormatFilter;
140 import net.pterodactylus.util.template.HtmlFilter;
141 import net.pterodactylus.util.template.MatchFilter;
142 import net.pterodactylus.util.template.ModFilter;
143 import net.pterodactylus.util.template.PaginationFilter;
144 import net.pterodactylus.util.template.ReflectionAccessor;
145 import net.pterodactylus.util.template.ReplaceFilter;
146 import net.pterodactylus.util.template.StoreFilter;
147 import net.pterodactylus.util.template.Template;
148 import net.pterodactylus.util.template.TemplateContextFactory;
149 import net.pterodactylus.util.template.TemplateProvider;
150 import net.pterodactylus.util.template.XmlFilter;
151 import net.pterodactylus.util.web.RedirectPage;
152 import net.pterodactylus.util.web.TemplatePage;
154 import freenet.clients.http.SessionManager;
155 import freenet.clients.http.SessionManager.Session;
156 import freenet.clients.http.ToadletContainer;
157 import freenet.clients.http.ToadletContext;
158 import freenet.l10n.BaseL10n;
159 import freenet.support.api.HTTPRequest;
161 import com.google.common.base.Optional;
162 import com.google.common.collect.Collections2;
163 import com.google.common.collect.ImmutableSet;
164 import com.google.common.eventbus.Subscribe;
165 import com.google.inject.Inject;
168 * Bundles functionality that a web interface of a Freenet plugin needs, e.g.
169 * references to l10n helpers.
171 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
173 public class WebInterface {
176 private static final Logger logger = getLogger(WebInterface.class.getName());
178 /** The loaders for templates, pages, and classpath providers. */
179 private final Loaders loaders;
181 /** The notification manager. */
182 private final NotificationManager notificationManager = new NotificationManager();
184 /** The Sone plugin. */
185 private final SonePlugin sonePlugin;
187 /** The registered toadlets. */
188 private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
190 /** The form password. */
191 private final String formPassword;
193 /** The template context factory. */
194 private final TemplateContextFactory templateContextFactory;
196 /** The Sone text parser. */
197 private final SoneTextParser soneTextParser;
199 /** The parser filter. */
200 private final ParserFilter parserFilter;
202 private final ListNotificationFilter listNotificationFilter;
203 private final PostVisibilityFilter postVisibilityFilter;
204 private final ReplyVisibilityFilter replyVisibilityFilter;
206 /** The “new Sone” notification. */
207 private final ListNotification<Sone> newSoneNotification;
209 /** The “new post” notification. */
210 private final ListNotification<Post> newPostNotification;
212 /** The “new reply” notification. */
213 private final ListNotification<PostReply> newReplyNotification;
215 /** The invisible “local post” notification. */
216 private final ListNotification<Post> localPostNotification;
218 /** The invisible “local reply” notification. */
219 private final ListNotification<PostReply> localReplyNotification;
221 /** The “you have been mentioned” notification. */
222 private final ListNotification<Post> mentionNotification;
224 /** Notifications for sone inserts. */
225 private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
227 /** Sone locked notification ticker objects. */
228 private final Map<Sone, ScheduledFuture<?>> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap<Sone, ScheduledFuture<?>>());
230 /** The “Sone locked” notification. */
231 private final ListNotification<Sone> lockedSonesNotification;
233 /** The “new version” notification. */
234 private final TemplateNotification newVersionNotification;
236 /** The “inserting images” notification. */
237 private final ListNotification<Image> insertingImagesNotification;
239 /** The “inserted images” notification. */
240 private final ListNotification<Image> insertedImagesNotification;
242 /** The “image insert failed” notification. */
243 private final ListNotification<Image> imageInsertFailedNotification;
245 /** Scheduled executor for time-based notifications. */
246 private final ScheduledExecutorService ticker = Executors.newScheduledThreadPool(1);
249 * Creates a new web interface.
255 public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) {
256 this.sonePlugin = sonePlugin;
257 this.loaders = loaders;
258 this.listNotificationFilter = listNotificationFilter;
259 this.postVisibilityFilter = postVisibilityFilter;
260 this.replyVisibilityFilter = replyVisibilityFilter;
261 formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
262 soneTextParser = new SoneTextParser(getCore(), getCore());
264 templateContextFactory = new TemplateContextFactory();
265 templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
266 templateContextFactory.addAccessor(Collection.class, new CollectionAccessor());
267 templateContextFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
268 templateContextFactory.addAccessor(Post.class, new PostAccessor(getCore()));
269 templateContextFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
270 templateContextFactory.addAccessor(Album.class, new AlbumAccessor());
271 templateContextFactory.addAccessor(Image.class, new ImageAccessor());
272 templateContextFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
273 templateContextFactory.addAccessor(Trust.class, new TrustAccessor());
274 templateContextFactory.addAccessor(HTTPRequest.class, new HttpRequestAccessor());
275 templateContextFactory.addAccessor(Profile.class, new ProfileAccessor(getCore()));
276 templateContextFactory.addFilter("date", new DateFilter());
277 templateContextFactory.addFilter("html", new HtmlFilter());
278 templateContextFactory.addFilter("replace", new ReplaceFilter());
279 templateContextFactory.addFilter("store", new StoreFilter());
280 templateContextFactory.addFilter("l10n", new L10nFilter(this));
281 templateContextFactory.addFilter("substring", new SubstringFilter());
282 templateContextFactory.addFilter("xml", new XmlFilter());
283 templateContextFactory.addFilter("change", new RequestChangeFilter());
284 templateContextFactory.addFilter("match", new MatchFilter());
285 templateContextFactory.addFilter("css", new CssClassNameFilter());
286 templateContextFactory.addFilter("js", new JavascriptFilter());
287 templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), templateContextFactory, soneTextParser));
288 templateContextFactory.addFilter("reparse", new ReparseFilter());
289 templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
290 templateContextFactory.addFilter("format", new FormatFilter());
291 templateContextFactory.addFilter("sort", new CollectionSortFilter());
292 templateContextFactory.addFilter("image-link", new ImageLinkFilter(getCore(), templateContextFactory));
293 templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
294 templateContextFactory.addFilter("in", new ContainsFilter());
295 templateContextFactory.addFilter("unique", new UniqueElementFilter());
296 templateContextFactory.addFilter("mod", new ModFilter());
297 templateContextFactory.addFilter("paginate", new PaginationFilter());
298 templateContextFactory.addProvider(TemplateProvider.TEMPLATE_CONTEXT_PROVIDER);
299 templateContextFactory.addProvider(loaders.getTemplateProvider());
300 templateContextFactory.addTemplateObject("webInterface", this);
301 templateContextFactory.addTemplateObject("formPassword", formPassword);
303 /* create notifications. */
304 Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
305 newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
307 Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
308 newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
310 Template localPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
311 localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);
313 Template newReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
314 newReplyNotification = new ListNotification<PostReply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
316 Template localReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
317 localReplyNotification = new ListNotification<PostReply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);
319 Template mentionNotificationTemplate = loaders.loadTemplate("/templates/notify/mentionNotification.html");
320 mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
322 Template lockedSonesTemplate = loaders.loadTemplate("/templates/notify/lockedSonesNotification.html");
323 lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);
325 Template newVersionTemplate = loaders.loadTemplate("/templates/notify/newVersionNotification.html");
326 newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);
328 Template insertingImagesTemplate = loaders.loadTemplate("/templates/notify/inserting-images-notification.html");
329 insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);
331 Template insertedImagesTemplate = loaders.loadTemplate("/templates/notify/inserted-images-notification.html");
332 insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);
334 Template imageInsertFailedTemplate = loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html");
335 imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
343 * Returns the Sone core used by the Sone plugin.
345 * @return The Sone core
347 public Core getCore() {
348 return sonePlugin.core();
352 * Returns the template context factory of the web interface.
354 * @return The template context factory
356 public TemplateContextFactory getTemplateContextFactory() {
357 return templateContextFactory;
361 * Returns the current session, creating a new session if there is no
364 * @param toadletContenxt
365 * The toadlet context
366 * @return The current session, or {@code null} if there is no current
369 public Session getCurrentSession(ToadletContext toadletContenxt) {
370 return getCurrentSession(toadletContenxt, true);
374 * Returns the current session, creating a new session if there is no
375 * current session and {@code create} is {@code true}.
377 * @param toadletContenxt
378 * The toadlet context
380 * {@code true} to create a new session if there is no current
381 * session, {@code false} otherwise
382 * @return The current session, or {@code null} if there is no current
385 public Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
386 Session session = getSessionManager().useSession(toadletContenxt);
387 if (create && (session == null)) {
388 session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
394 * Returns the currently logged in Sone.
396 * @param toadletContext
397 * The toadlet context
398 * @return The currently logged in Sone, or {@code null} if no Sone is
399 * currently logged in
401 public Sone getCurrentSone(ToadletContext toadletContext) {
402 return getCurrentSone(toadletContext, true);
406 * Returns the currently logged in Sone.
408 * @param toadletContext
409 * The toadlet context
411 * {@code true} to create a new session if no session exists,
412 * {@code false} to not create a new session
413 * @return The currently logged in Sone, or {@code null} if no Sone is
414 * currently logged in
416 public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
417 Collection<Sone> localSones = getCore().getLocalSones();
418 if (localSones.size() == 1) {
419 return localSones.iterator().next();
421 return getCurrentSone(getCurrentSession(toadletContext, create));
425 * Returns the currently logged in Sone.
429 * @return The currently logged in Sone, or {@code null} if no Sone is
430 * currently logged in
432 public Sone getCurrentSone(Session session) {
433 if (session == null) {
436 String soneId = (String) session.getAttribute("Sone.CurrentSone");
437 if (soneId == null) {
440 return getCore().getLocalSone(soneId);
444 * Sets the currently logged in Sone.
446 * @param toadletContext
447 * The toadlet context
449 * The Sone to set as currently logged in
451 public void setCurrentSone(ToadletContext toadletContext, Sone sone) {
452 Session session = getCurrentSession(toadletContext);
454 session.removeAttribute("Sone.CurrentSone");
456 session.setAttribute("Sone.CurrentSone", sone.getId());
461 * Returns the notification manager.
463 * @return The notification manager
465 public NotificationManager getNotifications() {
466 return notificationManager;
470 public Optional<Notification> getNotification(@Nonnull String notificationId) {
471 return Optional.fromNullable(notificationManager.getNotification(notificationId));
475 public Collection<Notification> getNotifications(@Nullable Sone currentSone) {
476 return listNotificationFilter.filterNotifications(notificationManager.getNotifications(), currentSone);
480 * Returns the l10n helper of the node.
482 * @return The node’s l10n helper
484 public BaseL10n getL10n() {
485 return sonePlugin.l10n().getBase();
489 * Returns the session manager of the node.
491 * @return The node’s session manager
493 public SessionManager getSessionManager() {
494 return sonePlugin.pluginRespirator().getSessionManager("Sone");
498 * Returns the node’s form password.
500 * @return The form password
502 public String getFormPassword() {
507 * Returns the posts that have been announced as new in the
508 * {@link #newPostNotification}.
510 * @return The new posts
512 public Set<Post> getNewPosts() {
513 return ImmutableSet.<Post> builder().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).build();
517 public Collection<Post> getNewPosts(@Nullable Sone currentSone) {
518 Set<Post> allNewPosts = ImmutableSet.<Post> builder()
519 .addAll(newPostNotification.getElements())
520 .addAll(localPostNotification.getElements())
522 return from(allNewPosts).filter(postVisibilityFilter.isVisible(currentSone)).toSet();
526 * Returns the replies that have been announced as new in the
527 * {@link #newReplyNotification}.
529 * @return The new replies
531 public Set<PostReply> getNewReplies() {
532 return ImmutableSet.<PostReply> builder().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).build();
536 public Collection<PostReply> getNewReplies(@Nullable Sone currentSone) {
537 Set<PostReply> allNewReplies = ImmutableSet.<PostReply>builder()
538 .addAll(newReplyNotification.getElements())
539 .addAll(localReplyNotification.getElements())
541 return from(allNewReplies).filter(replyVisibilityFilter.isVisible(currentSone)).toSet();
545 * Sets whether the current start of the plugin is the first start. It is
546 * considered a first start if the configuration file does not exist.
549 * {@code true} if no configuration file existed when Sone was
550 * loaded, {@code false} otherwise
552 public void setFirstStart(boolean firstStart) {
554 Template firstStartNotificationTemplate = loaders.loadTemplate("/templates/notify/firstStartNotification.html");
555 Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate);
556 notificationManager.addNotification(firstStartNotification);
561 * Sets whether Sone was started with a fresh configuration file.
564 * {@code true} if Sone was started with a fresh configuration,
565 * {@code false} if the existing configuration could be read
567 public void setNewConfig(boolean newConfig) {
568 if (newConfig && !hasFirstStartNotification()) {
569 Template configNotReadNotificationTemplate = loaders.loadTemplate("/templates/notify/configNotReadNotification.html");
570 Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate);
571 notificationManager.addNotification(configNotReadNotification);
580 * Returns whether the first start notification is currently displayed.
582 * @return {@code true} if the first-start notification is currently
583 * displayed, {@code false} otherwise
585 private boolean hasFirstStartNotification() {
586 return notificationManager.getNotification("first-start-notification") != null;
594 * Starts the web interface and registers all toadlets.
596 public void start() {
599 /* notification templates. */
600 Template startupNotificationTemplate = loaders.loadTemplate("/templates/notify/startupNotification.html");
602 final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
603 notificationManager.addNotification(startupNotification);
605 ticker.schedule(new Runnable() {
609 startupNotification.dismiss();
611 }, 2, TimeUnit.MINUTES);
613 Template wotMissingNotificationTemplate = loaders.loadTemplate("/templates/notify/wotMissingNotification.html");
614 final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
615 ticker.scheduleAtFixedRate(new Runnable() {
618 @SuppressWarnings("synthetic-access")
620 if (getCore().getIdentityManager().isConnected()) {
621 wotMissingNotification.dismiss();
623 notificationManager.addNotification(wotMissingNotification);
627 }, 15, 15, TimeUnit.SECONDS);
631 * Stops the web interface and unregisters all toadlets.
634 unregisterToadlets();
635 ticker.shutdownNow();
643 * Register all toadlets.
645 private void registerToadlets() {
646 Template emptyTemplate = parse(new StringReader(""));
647 Template loginTemplate = loaders.loadTemplate("/templates/login.html");
648 Template indexTemplate = loaders.loadTemplate("/templates/index.html");
649 Template newTemplate = loaders.loadTemplate("/templates/new.html");
650 Template knownSonesTemplate = loaders.loadTemplate("/templates/knownSones.html");
651 Template createSoneTemplate = loaders.loadTemplate("/templates/createSone.html");
652 Template createPostTemplate = loaders.loadTemplate("/templates/createPost.html");
653 Template createReplyTemplate = loaders.loadTemplate("/templates/createReply.html");
654 Template bookmarksTemplate = loaders.loadTemplate("/templates/bookmarks.html");
655 Template searchTemplate = loaders.loadTemplate("/templates/search.html");
656 Template editProfileTemplate = loaders.loadTemplate("/templates/editProfile.html");
657 Template editProfileFieldTemplate = loaders.loadTemplate("/templates/editProfileField.html");
658 Template deleteProfileFieldTemplate = loaders.loadTemplate("/templates/deleteProfileField.html");
659 Template viewSoneTemplate = loaders.loadTemplate("/templates/viewSone.html");
660 Template viewPostTemplate = loaders.loadTemplate("/templates/viewPost.html");
661 Template deletePostTemplate = loaders.loadTemplate("/templates/deletePost.html");
662 Template deleteReplyTemplate = loaders.loadTemplate("/templates/deleteReply.html");
663 Template deleteSoneTemplate = loaders.loadTemplate("/templates/deleteSone.html");
664 Template imageBrowserTemplate = loaders.loadTemplate("/templates/imageBrowser.html");
665 Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
666 Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
667 Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
668 Template noPermissionTemplate = loaders.loadTemplate("/templates/noPermission.html");
669 Template emptyImageTitleTemplate = loaders.loadTemplate("/templates/emptyImageTitle.html");
670 Template emptyAlbumTitleTemplate = loaders.loadTemplate("/templates/emptyAlbumTitle.html");
671 Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
672 Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
673 Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
674 Template invalidTemplate = loaders.loadTemplate("/templates/invalid.html");
675 Template postTemplate = loaders.loadTemplate("/templates/include/viewPost.html");
676 Template replyTemplate = loaders.loadTemplate("/templates/include/viewReply.html");
677 Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
679 PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
680 pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
681 pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this, postVisibilityFilter), "Index"));
682 pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New"));
683 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
684 pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
685 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
686 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldPage(editProfileFieldTemplate, this)));
687 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this)));
688 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
689 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
690 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
691 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
692 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(emptyTemplate, this)));
693 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(emptyTemplate, this)));
694 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
695 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
696 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(emptyTemplate, this)));
697 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(emptyTemplate, this)));
698 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(emptyTemplate, this)));
699 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(emptyTemplate, this)));
700 pageToadlets.add(pageToadletFactory.createPageToadlet(new ImageBrowserPage(imageBrowserTemplate, this), "ImageBrowser"));
701 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateAlbumPage(createAlbumTemplate, this)));
702 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumPage(emptyTemplate, this)));
703 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this)));
704 pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this)));
705 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this)));
706 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this)));
707 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this)));
708 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this)));
709 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this)));
710 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownPage(emptyTemplate, this)));
711 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkPage(emptyTemplate, this)));
712 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkPage(emptyTemplate, this)));
713 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarksPage(bookmarksTemplate, this), "Bookmarks"));
714 pageToadlets.add(pageToadletFactory.createPageToadlet(new SearchPage(searchTemplate, this)));
715 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
716 pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
717 pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout"));
718 pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
719 pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue"));
720 pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.VERSION, SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
721 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
722 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this)));
723 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this)));
724 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
725 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
726 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css")));
727 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("javascript/", "/static/javascript/", "text/javascript")));
728 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("images/", "/static/images/", "image/png")));
729 pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage<FreenetRequest>("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
730 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetImagePage(this)));
731 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
732 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
733 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationsAjaxPage(this)));
734 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this)));
735 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostAjaxPage(this)));
736 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyAjaxPage(this)));
737 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
738 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetPostAjaxPage(this, postTemplate)));
739 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTimesAjaxPage(this)));
740 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownAjaxPage(this)));
741 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
742 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
743 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
744 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
745 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
746 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
747 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumAjaxPage(this)));
748 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter)));
749 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
750 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
751 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
752 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
753 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikeAjaxPage(this)));
754 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetLikesAjaxPage(this)));
755 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkAjaxPage(this)));
756 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkAjaxPage(this)));
757 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldAjaxPage(this)));
758 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldAjaxPage(this)));
759 pageToadlets.add(pageToadletFactory.createPageToadlet(new MoveProfileFieldAjaxPage(this)));
761 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
762 toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin);
763 for (PageToadlet toadlet : pageToadlets) {
764 String menuName = toadlet.getMenuName();
765 if (menuName != null) {
766 toadletContainer.register(toadlet, "Navigation.Menu.Sone.Name", toadlet.path(), true, "Navigation.Menu.Sone.Item." + menuName + ".Name", "Navigation.Menu.Sone.Item." + menuName + ".Tooltip", false, toadlet);
768 toadletContainer.register(toadlet, null, toadlet.path(), true, false);
774 * Unregisters all toadlets.
776 private void unregisterToadlets() {
777 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
778 for (PageToadlet pageToadlet : pageToadlets) {
779 toadletContainer.unregister(pageToadlet);
781 toadletContainer.getPageMaker().removeNavigationCategory("Navigation.Menu.Sone.Name");
785 * Returns all {@link Sone#isLocal() local Sone}s that are referenced by
786 * {@link SonePart}s in the given text (after parsing it using
787 * {@link SoneTextParser}).
791 * @return All mentioned local Sones
793 private Collection<Sone> getMentionedSones(String text) {
794 /* we need no context to find mentioned Sones. */
795 Set<Sone> mentionedSones = new HashSet<Sone>();
796 for (Part part : soneTextParser.parse(text, null)) {
797 if (part instanceof SonePart) {
798 mentionedSones.add(((SonePart) part).getSone());
801 return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
805 * Returns the Sone insert notification for the given Sone. If no
806 * notification for the given Sone exists, a new notification is created and
810 * The Sone to get the insert notification for
811 * @return The Sone insert notification
813 private TemplateNotification getSoneInsertNotification(Sone sone) {
814 synchronized (soneInsertNotifications) {
815 TemplateNotification templateNotification = soneInsertNotifications.get(sone);
816 if (templateNotification == null) {
817 templateNotification = new TemplateNotification(loaders.loadTemplate("/templates/notify/soneInsertNotification.html"));
818 templateNotification.set("insertSone", sone);
819 soneInsertNotifications.put(sone, templateNotification);
821 return templateNotification;
825 private boolean localSoneMentionedInNewPostOrReply(Post post) {
826 if (!post.getSone().isLocal()) {
827 if (!getMentionedSones(post.getText()).isEmpty() && !post.isKnown()) {
831 for (PostReply postReply : getCore().getReplies(post.getId())) {
832 if (postReply.getSone().isLocal()) {
835 if (!getMentionedSones(postReply.getText()).isEmpty() && !postReply.isKnown()) {
847 * Notifies the web interface that a new {@link Sone} was found.
849 * @param newSoneFoundEvent
853 public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
854 newSoneNotification.add(newSoneFoundEvent.sone());
855 if (!hasFirstStartNotification()) {
856 notificationManager.addNotification(newSoneNotification);
861 * Notifies the web interface that a new {@link Post} was found.
863 * @param newPostFoundEvent
867 public void newPostFound(NewPostFoundEvent newPostFoundEvent) {
868 Post post = newPostFoundEvent.post();
869 boolean isLocal = post.getSone().isLocal();
871 localPostNotification.add(post);
873 newPostNotification.add(post);
875 if (!hasFirstStartNotification()) {
876 notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
877 if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
878 mentionNotification.add(post);
879 notificationManager.addNotification(mentionNotification);
882 getCore().markPostKnown(post);
887 * Notifies the web interface that a new {@link PostReply} was found.
889 * @param newPostReplyFoundEvent
893 public void newReplyFound(NewPostReplyFoundEvent newPostReplyFoundEvent) {
894 PostReply reply = newPostReplyFoundEvent.postReply();
895 boolean isLocal = reply.getSone().isLocal();
897 localReplyNotification.add(reply);
899 newReplyNotification.add(reply);
901 if (!hasFirstStartNotification()) {
902 notificationManager.addNotification(isLocal ? localReplyNotification : newReplyNotification);
903 if (reply.getPost().isPresent() && localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
904 mentionNotification.add(reply.getPost().get());
905 notificationManager.addNotification(mentionNotification);
908 getCore().markReplyKnown(reply);
913 * Notifies the web interface that a {@link Sone} was marked as known.
915 * @param markSoneKnownEvent
919 public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
920 newSoneNotification.remove(markSoneKnownEvent.sone());
924 public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
925 removePost(markPostKnownEvent.post());
929 public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
930 removeReply(markPostReplyKnownEvent.postReply());
934 public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
935 newSoneNotification.remove(soneRemovedEvent.sone());
939 public void postRemoved(PostRemovedEvent postRemovedEvent) {
940 removePost(postRemovedEvent.post());
943 private void removePost(Post post) {
944 newPostNotification.remove(post);
945 localPostNotification.remove(post);
946 if (!localSoneMentionedInNewPostOrReply(post)) {
947 mentionNotification.remove(post);
952 public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
953 removeReply(postReplyRemovedEvent.postReply());
956 private void removeReply(PostReply reply) {
957 newReplyNotification.remove(reply);
958 localReplyNotification.remove(reply);
959 if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
960 mentionNotification.remove(reply.getPost().get());
965 * Notifies the web interface that a Sone was locked.
967 * @param soneLockedEvent
971 public void soneLocked(SoneLockedEvent soneLockedEvent) {
972 final Sone sone = soneLockedEvent.sone();
973 ScheduledFuture<?> tickerObject = ticker.schedule(new Runnable() {
976 @SuppressWarnings("synthetic-access")
978 lockedSonesNotification.add(sone);
979 notificationManager.addNotification(lockedSonesNotification);
981 }, 5, TimeUnit.MINUTES);
982 lockedSonesTickerObjects.put(sone, tickerObject);
986 * Notifies the web interface that a Sone was unlocked.
988 * @param soneUnlockedEvent
992 public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) {
993 lockedSonesNotification.remove(soneUnlockedEvent.sone());
994 lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()).cancel(false);
998 * Notifies the web interface that a {@link Sone} is being inserted.
1000 * @param soneInsertingEvent
1004 public void soneInserting(SoneInsertingEvent soneInsertingEvent) {
1005 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone());
1006 soneInsertNotification.set("soneStatus", "inserting");
1007 if (soneInsertingEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1008 notificationManager.addNotification(soneInsertNotification);
1013 * Notifies the web interface that a {@link Sone} was inserted.
1015 * @param soneInsertedEvent
1019 public void soneInserted(SoneInsertedEvent soneInsertedEvent) {
1020 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.sone());
1021 soneInsertNotification.set("soneStatus", "inserted");
1022 soneInsertNotification.set("insertDuration", soneInsertedEvent.insertDuration() / 1000);
1023 if (soneInsertedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1024 notificationManager.addNotification(soneInsertNotification);
1029 * Notifies the web interface that a {@link Sone} insert was aborted.
1031 * @param soneInsertAbortedEvent
1035 public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
1036 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
1037 soneInsertNotification.set("soneStatus", "insert-aborted");
1038 soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
1039 if (soneInsertAbortedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1040 notificationManager.addNotification(soneInsertNotification);
1045 * Notifies the web interface that a new Sone version was found.
1047 * @param updateFoundEvent
1051 public void updateFound(UpdateFoundEvent updateFoundEvent) {
1052 newVersionNotification.set("latestVersion", updateFoundEvent.version());
1053 newVersionNotification.set("latestEdition", updateFoundEvent.latestEdition());
1054 newVersionNotification.set("releaseTime", updateFoundEvent.releaseTime());
1055 newVersionNotification.set("disruptive", updateFoundEvent.disruptive());
1056 notificationManager.addNotification(newVersionNotification);
1060 * Notifies the web interface that an image insert was started
1062 * @param imageInsertStartedEvent
1066 public void imageInsertStarted(ImageInsertStartedEvent imageInsertStartedEvent) {
1067 insertingImagesNotification.add(imageInsertStartedEvent.image());
1068 notificationManager.addNotification(insertingImagesNotification);
1072 * Notifies the web interface that an {@link Image} insert was aborted.
1074 * @param imageInsertAbortedEvent
1078 public void imageInsertAborted(ImageInsertAbortedEvent imageInsertAbortedEvent) {
1079 insertingImagesNotification.remove(imageInsertAbortedEvent.image());
1083 * Notifies the web interface that an {@link Image} insert is finished.
1085 * @param imageInsertFinishedEvent
1089 public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
1090 insertingImagesNotification.remove(imageInsertFinishedEvent.image());
1091 insertedImagesNotification.add(imageInsertFinishedEvent.image());
1092 notificationManager.addNotification(insertedImagesNotification);
1096 * Notifies the web interface that an {@link Image} insert has failed.
1098 * @param imageInsertFailedEvent
1102 public void imageInsertFailed(ImageInsertFailedEvent imageInsertFailedEvent) {
1103 insertingImagesNotification.remove(imageInsertFailedEvent.image());
1104 imageInsertFailedNotification.add(imageInsertFailedEvent.image());
1105 notificationManager.addNotification(imageInsertFailedNotification);