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.RenderFilter;
91 import net.pterodactylus.sone.template.ReplyAccessor;
92 import net.pterodactylus.sone.template.ReplyGroupFilter;
93 import net.pterodactylus.sone.template.RequestChangeFilter;
94 import net.pterodactylus.sone.template.ShortenFilter;
95 import net.pterodactylus.sone.template.SoneAccessor;
96 import net.pterodactylus.sone.template.SubstringFilter;
97 import net.pterodactylus.sone.template.TrustAccessor;
98 import net.pterodactylus.sone.template.UniqueElementFilter;
99 import net.pterodactylus.sone.template.UnknownDateFilter;
100 import net.pterodactylus.sone.text.Part;
101 import net.pterodactylus.sone.text.SonePart;
102 import net.pterodactylus.sone.text.SoneTextParser;
103 import net.pterodactylus.sone.web.ajax.BookmarkAjaxPage;
104 import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
105 import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
106 import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
107 import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
108 import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
109 import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
110 import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
111 import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage;
112 import net.pterodactylus.sone.web.ajax.EditImageAjaxPage;
113 import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
114 import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
115 import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
116 import net.pterodactylus.sone.web.ajax.GetNotificationsAjaxPage;
117 import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
118 import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
119 import net.pterodactylus.sone.web.ajax.GetStatusAjaxPage;
120 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
121 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
122 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
123 import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
124 import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage;
125 import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
126 import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
127 import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage;
128 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
129 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
130 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
131 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
132 import net.pterodactylus.sone.web.page.FreenetRequest;
133 import net.pterodactylus.sone.web.page.PageToadlet;
134 import net.pterodactylus.sone.web.page.PageToadletFactory;
135 import net.pterodactylus.util.notify.Notification;
136 import net.pterodactylus.util.notify.NotificationManager;
137 import net.pterodactylus.util.notify.TemplateNotification;
138 import net.pterodactylus.util.template.CollectionSortFilter;
139 import net.pterodactylus.util.template.ContainsFilter;
140 import net.pterodactylus.util.template.DateFilter;
141 import net.pterodactylus.util.template.FormatFilter;
142 import net.pterodactylus.util.template.HtmlFilter;
143 import net.pterodactylus.util.template.MatchFilter;
144 import net.pterodactylus.util.template.ModFilter;
145 import net.pterodactylus.util.template.PaginationFilter;
146 import net.pterodactylus.util.template.ReflectionAccessor;
147 import net.pterodactylus.util.template.ReplaceFilter;
148 import net.pterodactylus.util.template.StoreFilter;
149 import net.pterodactylus.util.template.Template;
150 import net.pterodactylus.util.template.TemplateContextFactory;
151 import net.pterodactylus.util.template.TemplateProvider;
152 import net.pterodactylus.util.template.XmlFilter;
153 import net.pterodactylus.util.web.RedirectPage;
154 import net.pterodactylus.util.web.TemplatePage;
156 import freenet.clients.http.SessionManager;
157 import freenet.clients.http.SessionManager.Session;
158 import freenet.clients.http.ToadletContainer;
159 import freenet.clients.http.ToadletContext;
160 import freenet.l10n.BaseL10n;
161 import freenet.support.api.HTTPRequest;
163 import com.google.common.base.Optional;
164 import com.google.common.collect.Collections2;
165 import com.google.common.collect.ImmutableSet;
166 import com.google.common.eventbus.Subscribe;
167 import com.google.inject.Inject;
170 * Bundles functionality that a web interface of a Freenet plugin needs, e.g.
171 * references to l10n helpers.
173 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
175 public class WebInterface {
178 private static final Logger logger = getLogger(WebInterface.class.getName());
180 /** The loaders for templates, pages, and classpath providers. */
181 private final Loaders loaders;
183 /** The notification manager. */
184 private final NotificationManager notificationManager = new NotificationManager();
186 /** The Sone plugin. */
187 private final SonePlugin sonePlugin;
189 /** The registered toadlets. */
190 private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
192 /** The form password. */
193 private final String formPassword;
195 /** The template context factory. */
196 private final TemplateContextFactory templateContextFactory;
198 /** The Sone text parser. */
199 private final SoneTextParser soneTextParser;
201 /** The parser filter. */
202 private final ParserFilter parserFilter;
203 private final ShortenFilter shortenFilter;
204 private final RenderFilter renderFilter;
206 private final ListNotificationFilter listNotificationFilter;
207 private final PostVisibilityFilter postVisibilityFilter;
208 private final ReplyVisibilityFilter replyVisibilityFilter;
210 /** The “new Sone” notification. */
211 private final ListNotification<Sone> newSoneNotification;
213 /** The “new post” notification. */
214 private final ListNotification<Post> newPostNotification;
216 /** The “new reply” notification. */
217 private final ListNotification<PostReply> newReplyNotification;
219 /** The invisible “local post” notification. */
220 private final ListNotification<Post> localPostNotification;
222 /** The invisible “local reply” notification. */
223 private final ListNotification<PostReply> localReplyNotification;
225 /** The “you have been mentioned” notification. */
226 private final ListNotification<Post> mentionNotification;
228 /** Notifications for sone inserts. */
229 private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
231 /** Sone locked notification ticker objects. */
232 private final Map<Sone, ScheduledFuture<?>> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap<Sone, ScheduledFuture<?>>());
234 /** The “Sone locked” notification. */
235 private final ListNotification<Sone> lockedSonesNotification;
237 /** The “new version” notification. */
238 private final TemplateNotification newVersionNotification;
240 /** The “inserting images” notification. */
241 private final ListNotification<Image> insertingImagesNotification;
243 /** The “inserted images” notification. */
244 private final ListNotification<Image> insertedImagesNotification;
246 /** The “image insert failed” notification. */
247 private final ListNotification<Image> imageInsertFailedNotification;
249 /** Scheduled executor for time-based notifications. */
250 private final ScheduledExecutorService ticker = Executors.newScheduledThreadPool(1);
253 * Creates a new web interface.
259 public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter) {
260 this.sonePlugin = sonePlugin;
261 this.loaders = loaders;
262 this.listNotificationFilter = listNotificationFilter;
263 this.postVisibilityFilter = postVisibilityFilter;
264 this.replyVisibilityFilter = replyVisibilityFilter;
265 formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
266 soneTextParser = new SoneTextParser(getCore(), getCore());
268 templateContextFactory = new TemplateContextFactory();
269 templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
270 templateContextFactory.addAccessor(Collection.class, new CollectionAccessor());
271 templateContextFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
272 templateContextFactory.addAccessor(Post.class, new PostAccessor(getCore()));
273 templateContextFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
274 templateContextFactory.addAccessor(Album.class, new AlbumAccessor());
275 templateContextFactory.addAccessor(Image.class, new ImageAccessor());
276 templateContextFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
277 templateContextFactory.addAccessor(Trust.class, new TrustAccessor());
278 templateContextFactory.addAccessor(HTTPRequest.class, new HttpRequestAccessor());
279 templateContextFactory.addAccessor(Profile.class, new ProfileAccessor(getCore()));
280 templateContextFactory.addFilter("date", new DateFilter());
281 templateContextFactory.addFilter("html", new HtmlFilter());
282 templateContextFactory.addFilter("replace", new ReplaceFilter());
283 templateContextFactory.addFilter("store", new StoreFilter());
284 templateContextFactory.addFilter("l10n", new L10nFilter(this));
285 templateContextFactory.addFilter("substring", new SubstringFilter());
286 templateContextFactory.addFilter("xml", new XmlFilter());
287 templateContextFactory.addFilter("change", new RequestChangeFilter());
288 templateContextFactory.addFilter("match", new MatchFilter());
289 templateContextFactory.addFilter("css", new CssClassNameFilter());
290 templateContextFactory.addFilter("js", new JavascriptFilter());
291 templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), soneTextParser));
292 templateContextFactory.addFilter("shorten", shortenFilter = new ShortenFilter());
293 templateContextFactory.addFilter("render", renderFilter = new RenderFilter(getCore(), templateContextFactory));
294 templateContextFactory.addFilter("reparse", new ReparseFilter());
295 templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
296 templateContextFactory.addFilter("format", new FormatFilter());
297 templateContextFactory.addFilter("sort", new CollectionSortFilter());
298 templateContextFactory.addFilter("image-link", new ImageLinkFilter(getCore(), templateContextFactory));
299 templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
300 templateContextFactory.addFilter("in", new ContainsFilter());
301 templateContextFactory.addFilter("unique", new UniqueElementFilter());
302 templateContextFactory.addFilter("mod", new ModFilter());
303 templateContextFactory.addFilter("paginate", new PaginationFilter());
304 templateContextFactory.addProvider(TemplateProvider.TEMPLATE_CONTEXT_PROVIDER);
305 templateContextFactory.addProvider(loaders.getTemplateProvider());
306 templateContextFactory.addTemplateObject("webInterface", this);
307 templateContextFactory.addTemplateObject("formPassword", formPassword);
309 /* create notifications. */
310 Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
311 newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
313 Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
314 newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
316 Template localPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
317 localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);
319 Template newReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
320 newReplyNotification = new ListNotification<PostReply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
322 Template localReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
323 localReplyNotification = new ListNotification<PostReply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);
325 Template mentionNotificationTemplate = loaders.loadTemplate("/templates/notify/mentionNotification.html");
326 mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
328 Template lockedSonesTemplate = loaders.loadTemplate("/templates/notify/lockedSonesNotification.html");
329 lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);
331 Template newVersionTemplate = loaders.loadTemplate("/templates/notify/newVersionNotification.html");
332 newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);
334 Template insertingImagesTemplate = loaders.loadTemplate("/templates/notify/inserting-images-notification.html");
335 insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);
337 Template insertedImagesTemplate = loaders.loadTemplate("/templates/notify/inserted-images-notification.html");
338 insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);
340 Template imageInsertFailedTemplate = loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html");
341 imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
349 * Returns the Sone core used by the Sone plugin.
351 * @return The Sone core
353 public Core getCore() {
354 return sonePlugin.core();
358 * Returns the template context factory of the web interface.
360 * @return The template context factory
362 public TemplateContextFactory getTemplateContextFactory() {
363 return templateContextFactory;
367 * Returns the current session, creating a new session if there is no
370 * @param toadletContenxt
371 * The toadlet context
372 * @return The current session, or {@code null} if there is no current
375 public Session getCurrentSession(ToadletContext toadletContenxt) {
376 return getCurrentSession(toadletContenxt, true);
380 * Returns the current session, creating a new session if there is no
381 * current session and {@code create} is {@code true}.
383 * @param toadletContenxt
384 * The toadlet context
386 * {@code true} to create a new session if there is no current
387 * session, {@code false} otherwise
388 * @return The current session, or {@code null} if there is no current
391 public Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
392 Session session = getSessionManager().useSession(toadletContenxt);
393 if (create && (session == null)) {
394 session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
400 * Returns the currently logged in Sone.
402 * @param toadletContext
403 * The toadlet context
404 * @return The currently logged in Sone, or {@code null} if no Sone is
405 * currently logged in
407 public Sone getCurrentSone(ToadletContext toadletContext) {
408 return getCurrentSone(toadletContext, true);
412 * Returns the currently logged in Sone.
414 * @param toadletContext
415 * The toadlet context
417 * {@code true} to create a new session if no session exists,
418 * {@code false} to not create a new session
419 * @return The currently logged in Sone, or {@code null} if no Sone is
420 * currently logged in
422 public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
423 Collection<Sone> localSones = getCore().getLocalSones();
424 if (localSones.size() == 1) {
425 return localSones.iterator().next();
427 return getCurrentSone(getCurrentSession(toadletContext, create));
431 * Returns the currently logged in Sone.
435 * @return The currently logged in Sone, or {@code null} if no Sone is
436 * currently logged in
438 public Sone getCurrentSone(Session session) {
439 if (session == null) {
442 String soneId = (String) session.getAttribute("Sone.CurrentSone");
443 if (soneId == null) {
446 return getCore().getLocalSone(soneId);
450 * Sets the currently logged in Sone.
452 * @param toadletContext
453 * The toadlet context
455 * The Sone to set as currently logged in
457 public void setCurrentSone(ToadletContext toadletContext, Sone sone) {
458 Session session = getCurrentSession(toadletContext);
460 session.removeAttribute("Sone.CurrentSone");
462 session.setAttribute("Sone.CurrentSone", sone.getId());
467 * Returns the notification manager.
469 * @return The notification manager
471 public NotificationManager getNotifications() {
472 return notificationManager;
476 public Optional<Notification> getNotification(@Nonnull String notificationId) {
477 return Optional.fromNullable(notificationManager.getNotification(notificationId));
481 public Collection<Notification> getNotifications(@Nullable Sone currentSone) {
482 return listNotificationFilter.filterNotifications(notificationManager.getNotifications(), currentSone);
486 * Returns the l10n helper of the node.
488 * @return The node’s l10n helper
490 public BaseL10n getL10n() {
491 return sonePlugin.l10n().getBase();
495 * Returns the session manager of the node.
497 * @return The node’s session manager
499 public SessionManager getSessionManager() {
500 return sonePlugin.pluginRespirator().getSessionManager("Sone");
504 * Returns the node’s form password.
506 * @return The form password
508 public String getFormPassword() {
513 * Returns the posts that have been announced as new in the
514 * {@link #newPostNotification}.
516 * @return The new posts
518 public Set<Post> getNewPosts() {
519 return ImmutableSet.<Post> builder().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).build();
523 public Collection<Post> getNewPosts(@Nullable Sone currentSone) {
524 Set<Post> allNewPosts = ImmutableSet.<Post> builder()
525 .addAll(newPostNotification.getElements())
526 .addAll(localPostNotification.getElements())
528 return from(allNewPosts).filter(postVisibilityFilter.isVisible(currentSone)).toSet();
532 * Returns the replies that have been announced as new in the
533 * {@link #newReplyNotification}.
535 * @return The new replies
537 public Set<PostReply> getNewReplies() {
538 return ImmutableSet.<PostReply> builder().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).build();
542 public Collection<PostReply> getNewReplies(@Nullable Sone currentSone) {
543 Set<PostReply> allNewReplies = ImmutableSet.<PostReply>builder()
544 .addAll(newReplyNotification.getElements())
545 .addAll(localReplyNotification.getElements())
547 return from(allNewReplies).filter(replyVisibilityFilter.isVisible(currentSone)).toSet();
551 * Sets whether the current start of the plugin is the first start. It is
552 * considered a first start if the configuration file does not exist.
555 * {@code true} if no configuration file existed when Sone was
556 * loaded, {@code false} otherwise
558 public void setFirstStart(boolean firstStart) {
560 Template firstStartNotificationTemplate = loaders.loadTemplate("/templates/notify/firstStartNotification.html");
561 Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate);
562 notificationManager.addNotification(firstStartNotification);
567 * Sets whether Sone was started with a fresh configuration file.
570 * {@code true} if Sone was started with a fresh configuration,
571 * {@code false} if the existing configuration could be read
573 public void setNewConfig(boolean newConfig) {
574 if (newConfig && !hasFirstStartNotification()) {
575 Template configNotReadNotificationTemplate = loaders.loadTemplate("/templates/notify/configNotReadNotification.html");
576 Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate);
577 notificationManager.addNotification(configNotReadNotification);
586 * Returns whether the first start notification is currently displayed.
588 * @return {@code true} if the first-start notification is currently
589 * displayed, {@code false} otherwise
591 private boolean hasFirstStartNotification() {
592 return notificationManager.getNotification("first-start-notification") != null;
600 * Starts the web interface and registers all toadlets.
602 public void start() {
605 /* notification templates. */
606 Template startupNotificationTemplate = loaders.loadTemplate("/templates/notify/startupNotification.html");
608 final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
609 notificationManager.addNotification(startupNotification);
611 ticker.schedule(new Runnable() {
615 startupNotification.dismiss();
617 }, 2, TimeUnit.MINUTES);
619 Template wotMissingNotificationTemplate = loaders.loadTemplate("/templates/notify/wotMissingNotification.html");
620 final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
621 ticker.scheduleAtFixedRate(new Runnable() {
624 @SuppressWarnings("synthetic-access")
626 if (getCore().getIdentityManager().isConnected()) {
627 wotMissingNotification.dismiss();
629 notificationManager.addNotification(wotMissingNotification);
633 }, 15, 15, TimeUnit.SECONDS);
637 * Stops the web interface and unregisters all toadlets.
640 unregisterToadlets();
641 ticker.shutdownNow();
649 * Register all toadlets.
651 private void registerToadlets() {
652 Template emptyTemplate = parse(new StringReader(""));
653 Template loginTemplate = loaders.loadTemplate("/templates/login.html");
654 Template indexTemplate = loaders.loadTemplate("/templates/index.html");
655 Template newTemplate = loaders.loadTemplate("/templates/new.html");
656 Template knownSonesTemplate = loaders.loadTemplate("/templates/knownSones.html");
657 Template createSoneTemplate = loaders.loadTemplate("/templates/createSone.html");
658 Template createPostTemplate = loaders.loadTemplate("/templates/createPost.html");
659 Template createReplyTemplate = loaders.loadTemplate("/templates/createReply.html");
660 Template bookmarksTemplate = loaders.loadTemplate("/templates/bookmarks.html");
661 Template searchTemplate = loaders.loadTemplate("/templates/search.html");
662 Template editProfileTemplate = loaders.loadTemplate("/templates/editProfile.html");
663 Template editProfileFieldTemplate = loaders.loadTemplate("/templates/editProfileField.html");
664 Template deleteProfileFieldTemplate = loaders.loadTemplate("/templates/deleteProfileField.html");
665 Template viewSoneTemplate = loaders.loadTemplate("/templates/viewSone.html");
666 Template viewPostTemplate = loaders.loadTemplate("/templates/viewPost.html");
667 Template deletePostTemplate = loaders.loadTemplate("/templates/deletePost.html");
668 Template deleteReplyTemplate = loaders.loadTemplate("/templates/deleteReply.html");
669 Template deleteSoneTemplate = loaders.loadTemplate("/templates/deleteSone.html");
670 Template imageBrowserTemplate = loaders.loadTemplate("/templates/imageBrowser.html");
671 Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
672 Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
673 Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
674 Template noPermissionTemplate = loaders.loadTemplate("/templates/noPermission.html");
675 Template emptyImageTitleTemplate = loaders.loadTemplate("/templates/emptyImageTitle.html");
676 Template emptyAlbumTitleTemplate = loaders.loadTemplate("/templates/emptyAlbumTitle.html");
677 Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
678 Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
679 Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
680 Template invalidTemplate = loaders.loadTemplate("/templates/invalid.html");
681 Template postTemplate = loaders.loadTemplate("/templates/include/viewPost.html");
682 Template replyTemplate = loaders.loadTemplate("/templates/include/viewReply.html");
683 Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
685 PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
686 pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
687 pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this, postVisibilityFilter), "Index"));
688 pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New"));
689 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
690 pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
691 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
692 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldPage(editProfileFieldTemplate, this)));
693 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this)));
694 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
695 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
696 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
697 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
698 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(emptyTemplate, this)));
699 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(emptyTemplate, this)));
700 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
701 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
702 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(emptyTemplate, this)));
703 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(emptyTemplate, this)));
704 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(emptyTemplate, this)));
705 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(emptyTemplate, this)));
706 pageToadlets.add(pageToadletFactory.createPageToadlet(new ImageBrowserPage(imageBrowserTemplate, this), "ImageBrowser"));
707 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateAlbumPage(createAlbumTemplate, this)));
708 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumPage(emptyTemplate, this)));
709 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this)));
710 pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this)));
711 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this)));
712 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this)));
713 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this)));
714 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this)));
715 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this)));
716 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownPage(emptyTemplate, this)));
717 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkPage(emptyTemplate, this)));
718 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkPage(emptyTemplate, this)));
719 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarksPage(bookmarksTemplate, this), "Bookmarks"));
720 pageToadlets.add(pageToadletFactory.createPageToadlet(new SearchPage(searchTemplate, this)));
721 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
722 pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
723 pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout"));
724 pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
725 pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue"));
726 pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.getPluginVersion(), SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
727 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
728 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this)));
729 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this)));
730 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
731 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
732 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css")));
733 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("javascript/", "/static/javascript/", "text/javascript")));
734 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("images/", "/static/images/", "image/png")));
735 pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage<FreenetRequest>("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
736 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetImagePage(this)));
737 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
738 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
739 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationsAjaxPage(this)));
740 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this)));
741 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostAjaxPage(this)));
742 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyAjaxPage(this)));
743 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
744 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetPostAjaxPage(this, postTemplate)));
745 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTimesAjaxPage(this)));
746 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownAjaxPage(this)));
747 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
748 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
749 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
750 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
751 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
752 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
753 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumAjaxPage(this)));
754 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter, shortenFilter, renderFilter)));
755 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
756 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
757 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
758 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
759 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikeAjaxPage(this)));
760 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetLikesAjaxPage(this)));
761 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkAjaxPage(this)));
762 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkAjaxPage(this)));
763 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldAjaxPage(this)));
764 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldAjaxPage(this)));
765 pageToadlets.add(pageToadletFactory.createPageToadlet(new MoveProfileFieldAjaxPage(this)));
767 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
768 toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin);
769 for (PageToadlet toadlet : pageToadlets) {
770 String menuName = toadlet.getMenuName();
771 if (menuName != null) {
772 toadletContainer.register(toadlet, "Navigation.Menu.Sone.Name", toadlet.path(), true, "Navigation.Menu.Sone.Item." + menuName + ".Name", "Navigation.Menu.Sone.Item." + menuName + ".Tooltip", false, toadlet);
774 toadletContainer.register(toadlet, null, toadlet.path(), true, false);
780 * Unregisters all toadlets.
782 private void unregisterToadlets() {
783 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
784 for (PageToadlet pageToadlet : pageToadlets) {
785 toadletContainer.unregister(pageToadlet);
787 toadletContainer.getPageMaker().removeNavigationCategory("Navigation.Menu.Sone.Name");
791 * Returns all {@link Sone#isLocal() local Sone}s that are referenced by
792 * {@link SonePart}s in the given text (after parsing it using
793 * {@link SoneTextParser}).
797 * @return All mentioned local Sones
799 private Collection<Sone> getMentionedSones(String text) {
800 /* we need no context to find mentioned Sones. */
801 Set<Sone> mentionedSones = new HashSet<Sone>();
802 for (Part part : soneTextParser.parse(text, null)) {
803 if (part instanceof SonePart) {
804 mentionedSones.add(((SonePart) part).getSone());
807 return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
811 * Returns the Sone insert notification for the given Sone. If no
812 * notification for the given Sone exists, a new notification is created and
816 * The Sone to get the insert notification for
817 * @return The Sone insert notification
819 private TemplateNotification getSoneInsertNotification(Sone sone) {
820 synchronized (soneInsertNotifications) {
821 TemplateNotification templateNotification = soneInsertNotifications.get(sone);
822 if (templateNotification == null) {
823 templateNotification = new TemplateNotification(loaders.loadTemplate("/templates/notify/soneInsertNotification.html"));
824 templateNotification.set("insertSone", sone);
825 soneInsertNotifications.put(sone, templateNotification);
827 return templateNotification;
831 private boolean localSoneMentionedInNewPostOrReply(Post post) {
832 if (!post.getSone().isLocal()) {
833 if (!getMentionedSones(post.getText()).isEmpty() && !post.isKnown()) {
837 for (PostReply postReply : getCore().getReplies(post.getId())) {
838 if (postReply.getSone().isLocal()) {
841 if (!getMentionedSones(postReply.getText()).isEmpty() && !postReply.isKnown()) {
853 * Notifies the web interface that a new {@link Sone} was found.
855 * @param newSoneFoundEvent
859 public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
860 newSoneNotification.add(newSoneFoundEvent.sone());
861 if (!hasFirstStartNotification()) {
862 notificationManager.addNotification(newSoneNotification);
867 * Notifies the web interface that a new {@link Post} was found.
869 * @param newPostFoundEvent
873 public void newPostFound(NewPostFoundEvent newPostFoundEvent) {
874 Post post = newPostFoundEvent.post();
875 boolean isLocal = post.getSone().isLocal();
877 localPostNotification.add(post);
879 newPostNotification.add(post);
881 if (!hasFirstStartNotification()) {
882 notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
883 if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
884 mentionNotification.add(post);
885 notificationManager.addNotification(mentionNotification);
888 getCore().markPostKnown(post);
893 * Notifies the web interface that a new {@link PostReply} was found.
895 * @param newPostReplyFoundEvent
899 public void newReplyFound(NewPostReplyFoundEvent newPostReplyFoundEvent) {
900 PostReply reply = newPostReplyFoundEvent.postReply();
901 boolean isLocal = reply.getSone().isLocal();
903 localReplyNotification.add(reply);
905 newReplyNotification.add(reply);
907 if (!hasFirstStartNotification()) {
908 notificationManager.addNotification(isLocal ? localReplyNotification : newReplyNotification);
909 if (reply.getPost().isPresent() && localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
910 mentionNotification.add(reply.getPost().get());
911 notificationManager.addNotification(mentionNotification);
914 getCore().markReplyKnown(reply);
919 * Notifies the web interface that a {@link Sone} was marked as known.
921 * @param markSoneKnownEvent
925 public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
926 newSoneNotification.remove(markSoneKnownEvent.sone());
930 public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
931 removePost(markPostKnownEvent.post());
935 public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
936 removeReply(markPostReplyKnownEvent.postReply());
940 public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
941 newSoneNotification.remove(soneRemovedEvent.sone());
945 public void postRemoved(PostRemovedEvent postRemovedEvent) {
946 removePost(postRemovedEvent.post());
949 private void removePost(Post post) {
950 newPostNotification.remove(post);
951 localPostNotification.remove(post);
952 if (!localSoneMentionedInNewPostOrReply(post)) {
953 mentionNotification.remove(post);
958 public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
959 removeReply(postReplyRemovedEvent.postReply());
962 private void removeReply(PostReply reply) {
963 newReplyNotification.remove(reply);
964 localReplyNotification.remove(reply);
965 if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
966 mentionNotification.remove(reply.getPost().get());
971 * Notifies the web interface that a Sone was locked.
973 * @param soneLockedEvent
977 public void soneLocked(SoneLockedEvent soneLockedEvent) {
978 final Sone sone = soneLockedEvent.sone();
979 ScheduledFuture<?> tickerObject = ticker.schedule(new Runnable() {
982 @SuppressWarnings("synthetic-access")
984 lockedSonesNotification.add(sone);
985 notificationManager.addNotification(lockedSonesNotification);
987 }, 5, TimeUnit.MINUTES);
988 lockedSonesTickerObjects.put(sone, tickerObject);
992 * Notifies the web interface that a Sone was unlocked.
994 * @param soneUnlockedEvent
998 public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) {
999 lockedSonesNotification.remove(soneUnlockedEvent.sone());
1000 lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()).cancel(false);
1004 * Notifies the web interface that a {@link Sone} is being inserted.
1006 * @param soneInsertingEvent
1010 public void soneInserting(SoneInsertingEvent soneInsertingEvent) {
1011 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone());
1012 soneInsertNotification.set("soneStatus", "inserting");
1013 if (soneInsertingEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1014 notificationManager.addNotification(soneInsertNotification);
1019 * Notifies the web interface that a {@link Sone} was inserted.
1021 * @param soneInsertedEvent
1025 public void soneInserted(SoneInsertedEvent soneInsertedEvent) {
1026 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.sone());
1027 soneInsertNotification.set("soneStatus", "inserted");
1028 soneInsertNotification.set("insertDuration", soneInsertedEvent.insertDuration() / 1000);
1029 if (soneInsertedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1030 notificationManager.addNotification(soneInsertNotification);
1035 * Notifies the web interface that a {@link Sone} insert was aborted.
1037 * @param soneInsertAbortedEvent
1041 public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
1042 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
1043 soneInsertNotification.set("soneStatus", "insert-aborted");
1044 soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
1045 if (soneInsertAbortedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1046 notificationManager.addNotification(soneInsertNotification);
1051 * Notifies the web interface that a new Sone version was found.
1053 * @param updateFoundEvent
1057 public void updateFound(UpdateFoundEvent updateFoundEvent) {
1058 newVersionNotification.set("latestVersion", updateFoundEvent.version());
1059 newVersionNotification.set("latestEdition", updateFoundEvent.latestEdition());
1060 newVersionNotification.set("releaseTime", updateFoundEvent.releaseTime());
1061 newVersionNotification.set("disruptive", updateFoundEvent.disruptive());
1062 notificationManager.addNotification(newVersionNotification);
1066 * Notifies the web interface that an image insert was started
1068 * @param imageInsertStartedEvent
1072 public void imageInsertStarted(ImageInsertStartedEvent imageInsertStartedEvent) {
1073 insertingImagesNotification.add(imageInsertStartedEvent.image());
1074 notificationManager.addNotification(insertingImagesNotification);
1078 * Notifies the web interface that an {@link Image} insert was aborted.
1080 * @param imageInsertAbortedEvent
1084 public void imageInsertAborted(ImageInsertAbortedEvent imageInsertAbortedEvent) {
1085 insertingImagesNotification.remove(imageInsertAbortedEvent.image());
1089 * Notifies the web interface that an {@link Image} insert is finished.
1091 * @param imageInsertFinishedEvent
1095 public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
1096 insertingImagesNotification.remove(imageInsertFinishedEvent.image());
1097 insertedImagesNotification.add(imageInsertFinishedEvent.image());
1098 notificationManager.addNotification(insertedImagesNotification);
1102 * Notifies the web interface that an {@link Image} insert has failed.
1104 * @param imageInsertFailedEvent
1108 public void imageInsertFailed(ImageInsertFailedEvent imageInsertFailedEvent) {
1109 insertingImagesNotification.remove(imageInsertFailedEvent.image());
1110 imageInsertFailedNotification.add(imageInsertFailedEvent.image());
1111 notificationManager.addNotification(imageInsertFailedNotification);