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.ImageLoader;
44 import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
45 import net.pterodactylus.sone.core.event.ImageInsertFailedEvent;
46 import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
47 import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
48 import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
49 import net.pterodactylus.sone.core.event.MarkPostReplyKnownEvent;
50 import net.pterodactylus.sone.core.event.MarkSoneKnownEvent;
51 import net.pterodactylus.sone.core.event.NewPostFoundEvent;
52 import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
53 import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
54 import net.pterodactylus.sone.core.event.PostRemovedEvent;
55 import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
56 import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
57 import net.pterodactylus.sone.core.event.SoneInsertedEvent;
58 import net.pterodactylus.sone.core.event.SoneInsertingEvent;
59 import net.pterodactylus.sone.core.event.SoneLockedEvent;
60 import net.pterodactylus.sone.core.event.SoneRemovedEvent;
61 import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
62 import net.pterodactylus.sone.core.event.UpdateFoundEvent;
63 import net.pterodactylus.sone.data.Album;
64 import net.pterodactylus.sone.data.Image;
65 import net.pterodactylus.sone.data.Post;
66 import net.pterodactylus.sone.data.PostReply;
67 import net.pterodactylus.sone.data.Profile;
68 import net.pterodactylus.sone.data.Reply;
69 import net.pterodactylus.sone.data.Sone;
70 import net.pterodactylus.sone.freenet.L10nFilter;
71 import net.pterodactylus.sone.freenet.wot.Identity;
72 import net.pterodactylus.sone.freenet.wot.Trust;
73 import net.pterodactylus.sone.main.Loaders;
74 import net.pterodactylus.sone.main.ReparseFilter;
75 import net.pterodactylus.sone.main.SonePlugin;
76 import net.pterodactylus.sone.notify.ListNotification;
77 import net.pterodactylus.sone.notify.ListNotificationFilter;
78 import net.pterodactylus.sone.notify.PostVisibilityFilter;
79 import net.pterodactylus.sone.notify.ReplyVisibilityFilter;
80 import net.pterodactylus.sone.template.AlbumAccessor;
81 import net.pterodactylus.sone.template.CollectionAccessor;
82 import net.pterodactylus.sone.template.CssClassNameFilter;
83 import net.pterodactylus.sone.template.HttpRequestAccessor;
84 import net.pterodactylus.sone.template.IdentityAccessor;
85 import net.pterodactylus.sone.template.ImageAccessor;
86 import net.pterodactylus.sone.template.ImageLinkFilter;
87 import net.pterodactylus.sone.template.JavascriptFilter;
88 import net.pterodactylus.sone.template.LinkedImagesFilter;
89 import net.pterodactylus.sone.template.ParserFilter;
90 import net.pterodactylus.sone.template.PostAccessor;
91 import net.pterodactylus.sone.template.ProfileAccessor;
92 import net.pterodactylus.sone.template.RenderFilter;
93 import net.pterodactylus.sone.template.ReplyAccessor;
94 import net.pterodactylus.sone.template.ReplyGroupFilter;
95 import net.pterodactylus.sone.template.RequestChangeFilter;
96 import net.pterodactylus.sone.template.ShortenFilter;
97 import net.pterodactylus.sone.template.SoneAccessor;
98 import net.pterodactylus.sone.template.SubstringFilter;
99 import net.pterodactylus.sone.template.TrustAccessor;
100 import net.pterodactylus.sone.template.UniqueElementFilter;
101 import net.pterodactylus.sone.template.UnknownDateFilter;
102 import net.pterodactylus.sone.text.Part;
103 import net.pterodactylus.sone.text.SonePart;
104 import net.pterodactylus.sone.text.SoneTextParser;
105 import net.pterodactylus.sone.web.ajax.BookmarkAjaxPage;
106 import net.pterodactylus.sone.web.ajax.CreatePostAjaxPage;
107 import net.pterodactylus.sone.web.ajax.CreateReplyAjaxPage;
108 import net.pterodactylus.sone.web.ajax.DeletePostAjaxPage;
109 import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
110 import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
111 import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
112 import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
113 import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage;
114 import net.pterodactylus.sone.web.ajax.EditImageAjaxPage;
115 import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
116 import net.pterodactylus.sone.web.ajax.FollowSoneAjaxPage;
117 import net.pterodactylus.sone.web.ajax.GetLikesAjaxPage;
118 import net.pterodactylus.sone.web.ajax.GetNotificationsAjaxPage;
119 import net.pterodactylus.sone.web.ajax.GetPostAjaxPage;
120 import net.pterodactylus.sone.web.ajax.GetReplyAjaxPage;
121 import net.pterodactylus.sone.web.ajax.GetStatusAjaxPage;
122 import net.pterodactylus.sone.web.ajax.GetTimesAjaxPage;
123 import net.pterodactylus.sone.web.ajax.GetTranslationPage;
124 import net.pterodactylus.sone.web.ajax.LikeAjaxPage;
125 import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
126 import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage;
127 import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
128 import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
129 import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage;
130 import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
131 import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
132 import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
133 import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
134 import net.pterodactylus.sone.web.page.FreenetRequest;
135 import net.pterodactylus.sone.web.page.PageToadlet;
136 import net.pterodactylus.sone.web.page.PageToadletFactory;
137 import net.pterodactylus.util.notify.Notification;
138 import net.pterodactylus.util.notify.NotificationManager;
139 import net.pterodactylus.util.notify.TemplateNotification;
140 import net.pterodactylus.util.template.CollectionSortFilter;
141 import net.pterodactylus.util.template.ContainsFilter;
142 import net.pterodactylus.util.template.DateFilter;
143 import net.pterodactylus.util.template.FormatFilter;
144 import net.pterodactylus.util.template.HtmlFilter;
145 import net.pterodactylus.util.template.MatchFilter;
146 import net.pterodactylus.util.template.ModFilter;
147 import net.pterodactylus.util.template.PaginationFilter;
148 import net.pterodactylus.util.template.ReflectionAccessor;
149 import net.pterodactylus.util.template.ReplaceFilter;
150 import net.pterodactylus.util.template.StoreFilter;
151 import net.pterodactylus.util.template.Template;
152 import net.pterodactylus.util.template.TemplateContextFactory;
153 import net.pterodactylus.util.template.TemplateProvider;
154 import net.pterodactylus.util.template.XmlFilter;
155 import net.pterodactylus.util.web.RedirectPage;
156 import net.pterodactylus.util.web.TemplatePage;
158 import freenet.clients.http.SessionManager;
159 import freenet.clients.http.SessionManager.Session;
160 import freenet.clients.http.ToadletContainer;
161 import freenet.clients.http.ToadletContext;
162 import freenet.l10n.BaseL10n;
163 import freenet.support.api.HTTPRequest;
165 import com.google.common.base.Optional;
166 import com.google.common.collect.Collections2;
167 import com.google.common.collect.ImmutableSet;
168 import com.google.common.eventbus.Subscribe;
169 import com.google.inject.Inject;
172 * Bundles functionality that a web interface of a Freenet plugin needs, e.g.
173 * references to l10n helpers.
175 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
177 public class WebInterface {
180 private static final Logger logger = getLogger(WebInterface.class.getName());
182 /** The loaders for templates, pages, and classpath providers. */
183 private final Loaders loaders;
185 /** The notification manager. */
186 private final NotificationManager notificationManager = new NotificationManager();
188 /** The Sone plugin. */
189 private final SonePlugin sonePlugin;
191 /** The registered toadlets. */
192 private final List<PageToadlet> pageToadlets = new ArrayList<PageToadlet>();
194 /** The form password. */
195 private final String formPassword;
197 /** The template context factory. */
198 private final TemplateContextFactory templateContextFactory;
200 /** The Sone text parser. */
201 private final SoneTextParser soneTextParser;
203 /** The parser filter. */
204 private final ParserFilter parserFilter;
205 private final ShortenFilter shortenFilter;
206 private final RenderFilter renderFilter;
208 private final ListNotificationFilter listNotificationFilter;
209 private final PostVisibilityFilter postVisibilityFilter;
210 private final ReplyVisibilityFilter replyVisibilityFilter;
212 /** The “new Sone” notification. */
213 private final ListNotification<Sone> newSoneNotification;
215 /** The “new post” notification. */
216 private final ListNotification<Post> newPostNotification;
218 /** The “new reply” notification. */
219 private final ListNotification<PostReply> newReplyNotification;
221 /** The invisible “local post” notification. */
222 private final ListNotification<Post> localPostNotification;
224 /** The invisible “local reply” notification. */
225 private final ListNotification<PostReply> localReplyNotification;
227 /** The “you have been mentioned” notification. */
228 private final ListNotification<Post> mentionNotification;
230 /** Notifications for sone inserts. */
231 private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
233 /** Sone locked notification ticker objects. */
234 private final Map<Sone, ScheduledFuture<?>> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap<Sone, ScheduledFuture<?>>());
236 /** The “Sone locked” notification. */
237 private final ListNotification<Sone> lockedSonesNotification;
239 /** The “new version” notification. */
240 private final TemplateNotification newVersionNotification;
242 /** The “inserting images” notification. */
243 private final ListNotification<Image> insertingImagesNotification;
245 /** The “inserted images” notification. */
246 private final ListNotification<Image> insertedImagesNotification;
248 /** The “image insert failed” notification. */
249 private final ListNotification<Image> imageInsertFailedNotification;
251 /** Scheduled executor for time-based notifications. */
252 private final ScheduledExecutorService ticker = Executors.newScheduledThreadPool(1);
255 * Creates a new web interface.
261 public WebInterface(SonePlugin sonePlugin, Loaders loaders, ListNotificationFilter listNotificationFilter, PostVisibilityFilter postVisibilityFilter, ReplyVisibilityFilter replyVisibilityFilter, ImageLoader imageLoader) {
262 this.sonePlugin = sonePlugin;
263 this.loaders = loaders;
264 this.listNotificationFilter = listNotificationFilter;
265 this.postVisibilityFilter = postVisibilityFilter;
266 this.replyVisibilityFilter = replyVisibilityFilter;
267 formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
268 soneTextParser = new SoneTextParser(getCore(), getCore());
270 templateContextFactory = new TemplateContextFactory();
271 templateContextFactory.addAccessor(Object.class, new ReflectionAccessor());
272 templateContextFactory.addAccessor(Collection.class, new CollectionAccessor());
273 templateContextFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
274 templateContextFactory.addAccessor(Post.class, new PostAccessor(getCore()));
275 templateContextFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
276 templateContextFactory.addAccessor(Album.class, new AlbumAccessor());
277 templateContextFactory.addAccessor(Image.class, new ImageAccessor());
278 templateContextFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
279 templateContextFactory.addAccessor(Trust.class, new TrustAccessor());
280 templateContextFactory.addAccessor(HTTPRequest.class, new HttpRequestAccessor());
281 templateContextFactory.addAccessor(Profile.class, new ProfileAccessor(getCore()));
282 templateContextFactory.addFilter("date", new DateFilter());
283 templateContextFactory.addFilter("html", new HtmlFilter());
284 templateContextFactory.addFilter("replace", new ReplaceFilter());
285 templateContextFactory.addFilter("store", new StoreFilter());
286 templateContextFactory.addFilter("l10n", new L10nFilter(this));
287 templateContextFactory.addFilter("substring", new SubstringFilter());
288 templateContextFactory.addFilter("xml", new XmlFilter());
289 templateContextFactory.addFilter("change", new RequestChangeFilter());
290 templateContextFactory.addFilter("match", new MatchFilter());
291 templateContextFactory.addFilter("css", new CssClassNameFilter());
292 templateContextFactory.addFilter("js", new JavascriptFilter());
293 templateContextFactory.addFilter("parse", parserFilter = new ParserFilter(getCore(), soneTextParser));
294 templateContextFactory.addFilter("shorten", shortenFilter = new ShortenFilter());
295 templateContextFactory.addFilter("render", renderFilter = new RenderFilter(getCore(), templateContextFactory));
296 templateContextFactory.addFilter("linked-images", new LinkedImagesFilter(imageLoader));
297 templateContextFactory.addFilter("reparse", new ReparseFilter());
298 templateContextFactory.addFilter("unknown", new UnknownDateFilter(getL10n(), "View.Sone.Text.UnknownDate"));
299 templateContextFactory.addFilter("format", new FormatFilter());
300 templateContextFactory.addFilter("sort", new CollectionSortFilter());
301 templateContextFactory.addFilter("image-link", new ImageLinkFilter(getCore(), templateContextFactory));
302 templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
303 templateContextFactory.addFilter("in", new ContainsFilter());
304 templateContextFactory.addFilter("unique", new UniqueElementFilter());
305 templateContextFactory.addFilter("mod", new ModFilter());
306 templateContextFactory.addFilter("paginate", new PaginationFilter());
307 templateContextFactory.addProvider(TemplateProvider.TEMPLATE_CONTEXT_PROVIDER);
308 templateContextFactory.addProvider(loaders.getTemplateProvider());
309 templateContextFactory.addTemplateObject("webInterface", this);
310 templateContextFactory.addTemplateObject("formPassword", formPassword);
312 /* create notifications. */
313 Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
314 newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
316 Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
317 newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);
319 Template localPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
320 localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);
322 Template newReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
323 newReplyNotification = new ListNotification<PostReply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);
325 Template localReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html");
326 localReplyNotification = new ListNotification<PostReply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);
328 Template mentionNotificationTemplate = loaders.loadTemplate("/templates/notify/mentionNotification.html");
329 mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
331 Template lockedSonesTemplate = loaders.loadTemplate("/templates/notify/lockedSonesNotification.html");
332 lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);
334 Template newVersionTemplate = loaders.loadTemplate("/templates/notify/newVersionNotification.html");
335 newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);
337 Template insertingImagesTemplate = loaders.loadTemplate("/templates/notify/inserting-images-notification.html");
338 insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);
340 Template insertedImagesTemplate = loaders.loadTemplate("/templates/notify/inserted-images-notification.html");
341 insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);
343 Template imageInsertFailedTemplate = loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html");
344 imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
352 * Returns the Sone core used by the Sone plugin.
354 * @return The Sone core
356 public Core getCore() {
357 return sonePlugin.core();
361 * Returns the template context factory of the web interface.
363 * @return The template context factory
365 public TemplateContextFactory getTemplateContextFactory() {
366 return templateContextFactory;
370 * Returns the current session, creating a new session if there is no
373 * @param toadletContenxt
374 * The toadlet context
375 * @return The current session, or {@code null} if there is no current
378 public Session getCurrentSession(ToadletContext toadletContenxt) {
379 return getCurrentSession(toadletContenxt, true);
383 * Returns the current session, creating a new session if there is no
384 * current session and {@code create} is {@code true}.
386 * @param toadletContenxt
387 * The toadlet context
389 * {@code true} to create a new session if there is no current
390 * session, {@code false} otherwise
391 * @return The current session, or {@code null} if there is no current
394 public Session getCurrentSession(ToadletContext toadletContenxt, boolean create) {
395 Session session = getSessionManager().useSession(toadletContenxt);
396 if (create && (session == null)) {
397 session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
403 * Returns the currently logged in Sone.
405 * @param toadletContext
406 * The toadlet context
407 * @return The currently logged in Sone, or {@code null} if no Sone is
408 * currently logged in
410 public Sone getCurrentSone(ToadletContext toadletContext) {
411 return getCurrentSone(toadletContext, true);
415 * Returns the currently logged in Sone.
417 * @param toadletContext
418 * The toadlet context
420 * {@code true} to create a new session if no session exists,
421 * {@code false} to not create a new session
422 * @return The currently logged in Sone, or {@code null} if no Sone is
423 * currently logged in
425 public Sone getCurrentSone(ToadletContext toadletContext, boolean create) {
426 Collection<Sone> localSones = getCore().getLocalSones();
427 if (localSones.size() == 1) {
428 return localSones.iterator().next();
430 return getCurrentSone(getCurrentSession(toadletContext, create));
434 * Returns the currently logged in Sone.
438 * @return The currently logged in Sone, or {@code null} if no Sone is
439 * currently logged in
441 public Sone getCurrentSone(Session session) {
442 if (session == null) {
445 String soneId = (String) session.getAttribute("Sone.CurrentSone");
446 if (soneId == null) {
449 return getCore().getLocalSone(soneId);
453 * Sets the currently logged in Sone.
455 * @param toadletContext
456 * The toadlet context
458 * The Sone to set as currently logged in
460 public void setCurrentSone(ToadletContext toadletContext, Sone sone) {
461 Session session = getCurrentSession(toadletContext);
463 session.removeAttribute("Sone.CurrentSone");
465 session.setAttribute("Sone.CurrentSone", sone.getId());
470 * Returns the notification manager.
472 * @return The notification manager
474 public NotificationManager getNotifications() {
475 return notificationManager;
479 public Optional<Notification> getNotification(@Nonnull String notificationId) {
480 return Optional.fromNullable(notificationManager.getNotification(notificationId));
484 public Collection<Notification> getNotifications(@Nullable Sone currentSone) {
485 return listNotificationFilter.filterNotifications(notificationManager.getNotifications(), currentSone);
489 * Returns the l10n helper of the node.
491 * @return The node’s l10n helper
493 public BaseL10n getL10n() {
494 return sonePlugin.l10n().getBase();
498 * Returns the session manager of the node.
500 * @return The node’s session manager
502 public SessionManager getSessionManager() {
503 return sonePlugin.pluginRespirator().getSessionManager("Sone");
507 * Returns the node’s form password.
509 * @return The form password
511 public String getFormPassword() {
516 * Returns the posts that have been announced as new in the
517 * {@link #newPostNotification}.
519 * @return The new posts
521 public Set<Post> getNewPosts() {
522 return ImmutableSet.<Post> builder().addAll(newPostNotification.getElements()).addAll(localPostNotification.getElements()).build();
526 public Collection<Post> getNewPosts(@Nullable Sone currentSone) {
527 Set<Post> allNewPosts = ImmutableSet.<Post> builder()
528 .addAll(newPostNotification.getElements())
529 .addAll(localPostNotification.getElements())
531 return from(allNewPosts).filter(postVisibilityFilter.isVisible(currentSone)).toSet();
535 * Returns the replies that have been announced as new in the
536 * {@link #newReplyNotification}.
538 * @return The new replies
540 public Set<PostReply> getNewReplies() {
541 return ImmutableSet.<PostReply> builder().addAll(newReplyNotification.getElements()).addAll(localReplyNotification.getElements()).build();
545 public Collection<PostReply> getNewReplies(@Nullable Sone currentSone) {
546 Set<PostReply> allNewReplies = ImmutableSet.<PostReply>builder()
547 .addAll(newReplyNotification.getElements())
548 .addAll(localReplyNotification.getElements())
550 return from(allNewReplies).filter(replyVisibilityFilter.isVisible(currentSone)).toSet();
554 * Sets whether the current start of the plugin is the first start. It is
555 * considered a first start if the configuration file does not exist.
558 * {@code true} if no configuration file existed when Sone was
559 * loaded, {@code false} otherwise
561 public void setFirstStart(boolean firstStart) {
563 Template firstStartNotificationTemplate = loaders.loadTemplate("/templates/notify/firstStartNotification.html");
564 Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate);
565 notificationManager.addNotification(firstStartNotification);
570 * Sets whether Sone was started with a fresh configuration file.
573 * {@code true} if Sone was started with a fresh configuration,
574 * {@code false} if the existing configuration could be read
576 public void setNewConfig(boolean newConfig) {
577 if (newConfig && !hasFirstStartNotification()) {
578 Template configNotReadNotificationTemplate = loaders.loadTemplate("/templates/notify/configNotReadNotification.html");
579 Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate);
580 notificationManager.addNotification(configNotReadNotification);
589 * Returns whether the first start notification is currently displayed.
591 * @return {@code true} if the first-start notification is currently
592 * displayed, {@code false} otherwise
594 private boolean hasFirstStartNotification() {
595 return notificationManager.getNotification("first-start-notification") != null;
603 * Starts the web interface and registers all toadlets.
605 public void start() {
608 /* notification templates. */
609 Template startupNotificationTemplate = loaders.loadTemplate("/templates/notify/startupNotification.html");
611 final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
612 notificationManager.addNotification(startupNotification);
614 ticker.schedule(new Runnable() {
618 startupNotification.dismiss();
620 }, 2, TimeUnit.MINUTES);
622 Template wotMissingNotificationTemplate = loaders.loadTemplate("/templates/notify/wotMissingNotification.html");
623 final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
624 ticker.scheduleAtFixedRate(new Runnable() {
627 @SuppressWarnings("synthetic-access")
629 if (getCore().getIdentityManager().isConnected()) {
630 wotMissingNotification.dismiss();
632 notificationManager.addNotification(wotMissingNotification);
636 }, 15, 15, TimeUnit.SECONDS);
640 * Stops the web interface and unregisters all toadlets.
643 unregisterToadlets();
644 ticker.shutdownNow();
652 * Register all toadlets.
654 private void registerToadlets() {
655 Template emptyTemplate = parse(new StringReader(""));
656 Template loginTemplate = loaders.loadTemplate("/templates/login.html");
657 Template indexTemplate = loaders.loadTemplate("/templates/index.html");
658 Template newTemplate = loaders.loadTemplate("/templates/new.html");
659 Template knownSonesTemplate = loaders.loadTemplate("/templates/knownSones.html");
660 Template createSoneTemplate = loaders.loadTemplate("/templates/createSone.html");
661 Template createPostTemplate = loaders.loadTemplate("/templates/createPost.html");
662 Template createReplyTemplate = loaders.loadTemplate("/templates/createReply.html");
663 Template bookmarksTemplate = loaders.loadTemplate("/templates/bookmarks.html");
664 Template searchTemplate = loaders.loadTemplate("/templates/search.html");
665 Template editProfileTemplate = loaders.loadTemplate("/templates/editProfile.html");
666 Template editProfileFieldTemplate = loaders.loadTemplate("/templates/editProfileField.html");
667 Template deleteProfileFieldTemplate = loaders.loadTemplate("/templates/deleteProfileField.html");
668 Template viewSoneTemplate = loaders.loadTemplate("/templates/viewSone.html");
669 Template viewPostTemplate = loaders.loadTemplate("/templates/viewPost.html");
670 Template deletePostTemplate = loaders.loadTemplate("/templates/deletePost.html");
671 Template deleteReplyTemplate = loaders.loadTemplate("/templates/deleteReply.html");
672 Template deleteSoneTemplate = loaders.loadTemplate("/templates/deleteSone.html");
673 Template imageBrowserTemplate = loaders.loadTemplate("/templates/imageBrowser.html");
674 Template createAlbumTemplate = loaders.loadTemplate("/templates/createAlbum.html");
675 Template deleteAlbumTemplate = loaders.loadTemplate("/templates/deleteAlbum.html");
676 Template deleteImageTemplate = loaders.loadTemplate("/templates/deleteImage.html");
677 Template noPermissionTemplate = loaders.loadTemplate("/templates/noPermission.html");
678 Template emptyImageTitleTemplate = loaders.loadTemplate("/templates/emptyImageTitle.html");
679 Template emptyAlbumTitleTemplate = loaders.loadTemplate("/templates/emptyAlbumTitle.html");
680 Template optionsTemplate = loaders.loadTemplate("/templates/options.html");
681 Template rescueTemplate = loaders.loadTemplate("/templates/rescue.html");
682 Template aboutTemplate = loaders.loadTemplate("/templates/about.html");
683 Template invalidTemplate = loaders.loadTemplate("/templates/invalid.html");
684 Template postTemplate = loaders.loadTemplate("/templates/include/viewPost.html");
685 Template replyTemplate = loaders.loadTemplate("/templates/include/viewReply.html");
686 Template openSearchTemplate = loaders.loadTemplate("/templates/xml/OpenSearch.xml");
688 PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
689 pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
690 pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this, postVisibilityFilter), "Index"));
691 pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New"));
692 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateSonePage(createSoneTemplate, this), "CreateSone"));
693 pageToadlets.add(pageToadletFactory.createPageToadlet(new KnownSonesPage(knownSonesTemplate, this), "KnownSones"));
694 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfilePage(editProfileTemplate, this), "EditProfile"));
695 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldPage(editProfileFieldTemplate, this)));
696 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldPage(deleteProfileFieldTemplate, this)));
697 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostPage(createPostTemplate, this)));
698 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyPage(createReplyTemplate, this)));
699 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewSonePage(viewSoneTemplate, this)));
700 pageToadlets.add(pageToadletFactory.createPageToadlet(new ViewPostPage(viewPostTemplate, this)));
701 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikePage(emptyTemplate, this)));
702 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikePage(emptyTemplate, this)));
703 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostPage(deletePostTemplate, this)));
704 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyPage(deleteReplyTemplate, this)));
705 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSonePage(emptyTemplate, this)));
706 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSonePage(emptyTemplate, this)));
707 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSonePage(emptyTemplate, this)));
708 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSonePage(emptyTemplate, this)));
709 pageToadlets.add(pageToadletFactory.createPageToadlet(new ImageBrowserPage(imageBrowserTemplate, this), "ImageBrowser"));
710 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateAlbumPage(createAlbumTemplate, this)));
711 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumPage(emptyTemplate, this)));
712 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteAlbumPage(deleteAlbumTemplate, this)));
713 pageToadlets.add(pageToadletFactory.createPageToadlet(new UploadImagePage(invalidTemplate, this)));
714 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImagePage(emptyTemplate, this)));
715 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteImagePage(deleteImageTemplate, this)));
716 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustPage(emptyTemplate, this)));
717 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustPage(emptyTemplate, this)));
718 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustPage(emptyTemplate, this)));
719 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownPage(emptyTemplate, this)));
720 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkPage(emptyTemplate, this)));
721 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkPage(emptyTemplate, this)));
722 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarksPage(bookmarksTemplate, this), "Bookmarks"));
723 pageToadlets.add(pageToadletFactory.createPageToadlet(new SearchPage(searchTemplate, this)));
724 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteSonePage(deleteSoneTemplate, this), "DeleteSone"));
725 pageToadlets.add(pageToadletFactory.createPageToadlet(new LoginPage(loginTemplate, this), "Login"));
726 pageToadlets.add(pageToadletFactory.createPageToadlet(new LogoutPage(emptyTemplate, this), "Logout"));
727 pageToadlets.add(pageToadletFactory.createPageToadlet(new OptionsPage(optionsTemplate, this), "Options"));
728 pageToadlets.add(pageToadletFactory.createPageToadlet(new RescuePage(rescueTemplate, this), "Rescue"));
729 pageToadlets.add(pageToadletFactory.createPageToadlet(new AboutPage(aboutTemplate, this, SonePlugin.getPluginVersion(), SonePlugin.getYear(), SonePlugin.getHomepage()), "About"));
730 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("noPermission.html", noPermissionTemplate, "Page.NoPermission.Title", this)));
731 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyImageTitle.html", emptyImageTitleTemplate, "Page.EmptyImageTitle.Title", this)));
732 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("emptyAlbumTitle.html", emptyAlbumTitleTemplate, "Page.EmptyAlbumTitle.Title", this)));
733 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationPage(emptyTemplate, this)));
734 pageToadlets.add(pageToadletFactory.createPageToadlet(new SoneTemplatePage("invalid.html", invalidTemplate, "Page.Invalid.Title", this)));
735 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("css/", "/static/css/", "text/css")));
736 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("javascript/", "/static/javascript/", "text/javascript")));
737 pageToadlets.add(pageToadletFactory.createPageToadlet(loaders.<FreenetRequest>loadStaticPage("images/", "/static/images/", "image/png")));
738 pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage<FreenetRequest>("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate)));
739 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetImagePage(this)));
740 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this)));
741 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this)));
742 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetNotificationsAjaxPage(this)));
743 pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this)));
744 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreatePostAjaxPage(this)));
745 pageToadlets.add(pageToadletFactory.createPageToadlet(new CreateReplyAjaxPage(this)));
746 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetReplyAjaxPage(this, replyTemplate)));
747 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetPostAjaxPage(this, postTemplate)));
748 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTimesAjaxPage(this)));
749 pageToadlets.add(pageToadletFactory.createPageToadlet(new MarkAsKnownAjaxPage(this)));
750 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeletePostAjaxPage(this)));
751 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteReplyAjaxPage(this)));
752 pageToadlets.add(pageToadletFactory.createPageToadlet(new LockSoneAjaxPage(this)));
753 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlockSoneAjaxPage(this)));
754 pageToadlets.add(pageToadletFactory.createPageToadlet(new FollowSoneAjaxPage(this)));
755 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnfollowSoneAjaxPage(this)));
756 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditAlbumAjaxPage(this)));
757 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditImageAjaxPage(this, parserFilter, shortenFilter, renderFilter)));
758 pageToadlets.add(pageToadletFactory.createPageToadlet(new TrustAjaxPage(this)));
759 pageToadlets.add(pageToadletFactory.createPageToadlet(new DistrustAjaxPage(this)));
760 pageToadlets.add(pageToadletFactory.createPageToadlet(new UntrustAjaxPage(this)));
761 pageToadlets.add(pageToadletFactory.createPageToadlet(new LikeAjaxPage(this)));
762 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnlikeAjaxPage(this)));
763 pageToadlets.add(pageToadletFactory.createPageToadlet(new GetLikesAjaxPage(this)));
764 pageToadlets.add(pageToadletFactory.createPageToadlet(new BookmarkAjaxPage(this)));
765 pageToadlets.add(pageToadletFactory.createPageToadlet(new UnbookmarkAjaxPage(this)));
766 pageToadlets.add(pageToadletFactory.createPageToadlet(new EditProfileFieldAjaxPage(this)));
767 pageToadlets.add(pageToadletFactory.createPageToadlet(new DeleteProfileFieldAjaxPage(this)));
768 pageToadlets.add(pageToadletFactory.createPageToadlet(new MoveProfileFieldAjaxPage(this)));
770 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
771 toadletContainer.getPageMaker().addNavigationCategory("/Sone/index.html", "Navigation.Menu.Sone.Name", "Navigation.Menu.Sone.Tooltip", sonePlugin);
772 for (PageToadlet toadlet : pageToadlets) {
773 String menuName = toadlet.getMenuName();
774 if (menuName != null) {
775 toadletContainer.register(toadlet, "Navigation.Menu.Sone.Name", toadlet.path(), true, "Navigation.Menu.Sone.Item." + menuName + ".Name", "Navigation.Menu.Sone.Item." + menuName + ".Tooltip", false, toadlet);
777 toadletContainer.register(toadlet, null, toadlet.path(), true, false);
783 * Unregisters all toadlets.
785 private void unregisterToadlets() {
786 ToadletContainer toadletContainer = sonePlugin.pluginRespirator().getToadletContainer();
787 for (PageToadlet pageToadlet : pageToadlets) {
788 toadletContainer.unregister(pageToadlet);
790 toadletContainer.getPageMaker().removeNavigationCategory("Navigation.Menu.Sone.Name");
794 * Returns all {@link Sone#isLocal() local Sone}s that are referenced by
795 * {@link SonePart}s in the given text (after parsing it using
796 * {@link SoneTextParser}).
800 * @return All mentioned local Sones
802 private Collection<Sone> getMentionedSones(String text) {
803 /* we need no context to find mentioned Sones. */
804 Set<Sone> mentionedSones = new HashSet<Sone>();
805 for (Part part : soneTextParser.parse(text, null)) {
806 if (part instanceof SonePart) {
807 mentionedSones.add(((SonePart) part).getSone());
810 return Collections2.filter(mentionedSones, Sone.LOCAL_SONE_FILTER);
814 * Returns the Sone insert notification for the given Sone. If no
815 * notification for the given Sone exists, a new notification is created and
819 * The Sone to get the insert notification for
820 * @return The Sone insert notification
822 private TemplateNotification getSoneInsertNotification(Sone sone) {
823 synchronized (soneInsertNotifications) {
824 TemplateNotification templateNotification = soneInsertNotifications.get(sone);
825 if (templateNotification == null) {
826 templateNotification = new TemplateNotification(loaders.loadTemplate("/templates/notify/soneInsertNotification.html"));
827 templateNotification.set("insertSone", sone);
828 soneInsertNotifications.put(sone, templateNotification);
830 return templateNotification;
834 private boolean localSoneMentionedInNewPostOrReply(Post post) {
835 if (!post.getSone().isLocal()) {
836 if (!getMentionedSones(post.getText()).isEmpty() && !post.isKnown()) {
840 for (PostReply postReply : getCore().getReplies(post.getId())) {
841 if (postReply.getSone().isLocal()) {
844 if (!getMentionedSones(postReply.getText()).isEmpty() && !postReply.isKnown()) {
856 * Notifies the web interface that a new {@link Sone} was found.
858 * @param newSoneFoundEvent
862 public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
863 newSoneNotification.add(newSoneFoundEvent.sone());
864 if (!hasFirstStartNotification()) {
865 notificationManager.addNotification(newSoneNotification);
870 * Notifies the web interface that a new {@link Post} was found.
872 * @param newPostFoundEvent
876 public void newPostFound(NewPostFoundEvent newPostFoundEvent) {
877 Post post = newPostFoundEvent.post();
878 boolean isLocal = post.getSone().isLocal();
880 localPostNotification.add(post);
882 newPostNotification.add(post);
884 if (!hasFirstStartNotification()) {
885 notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
886 if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
887 mentionNotification.add(post);
888 notificationManager.addNotification(mentionNotification);
891 getCore().markPostKnown(post);
896 * Notifies the web interface that a new {@link PostReply} was found.
898 * @param newPostReplyFoundEvent
902 public void newReplyFound(NewPostReplyFoundEvent newPostReplyFoundEvent) {
903 PostReply reply = newPostReplyFoundEvent.postReply();
904 boolean isLocal = reply.getSone().isLocal();
906 localReplyNotification.add(reply);
908 newReplyNotification.add(reply);
910 if (!hasFirstStartNotification()) {
911 notificationManager.addNotification(isLocal ? localReplyNotification : newReplyNotification);
912 if (reply.getPost().isPresent() && localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
913 mentionNotification.add(reply.getPost().get());
914 notificationManager.addNotification(mentionNotification);
917 getCore().markReplyKnown(reply);
922 * Notifies the web interface that a {@link Sone} was marked as known.
924 * @param markSoneKnownEvent
928 public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
929 newSoneNotification.remove(markSoneKnownEvent.sone());
933 public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
934 removePost(markPostKnownEvent.post());
938 public void markReplyKnown(MarkPostReplyKnownEvent markPostReplyKnownEvent) {
939 removeReply(markPostReplyKnownEvent.postReply());
943 public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
944 newSoneNotification.remove(soneRemovedEvent.sone());
948 public void postRemoved(PostRemovedEvent postRemovedEvent) {
949 removePost(postRemovedEvent.post());
952 private void removePost(Post post) {
953 newPostNotification.remove(post);
954 localPostNotification.remove(post);
955 if (!localSoneMentionedInNewPostOrReply(post)) {
956 mentionNotification.remove(post);
961 public void replyRemoved(PostReplyRemovedEvent postReplyRemovedEvent) {
962 removeReply(postReplyRemovedEvent.postReply());
965 private void removeReply(PostReply reply) {
966 newReplyNotification.remove(reply);
967 localReplyNotification.remove(reply);
968 if (reply.getPost().isPresent() && !localSoneMentionedInNewPostOrReply(reply.getPost().get())) {
969 mentionNotification.remove(reply.getPost().get());
974 * Notifies the web interface that a Sone was locked.
976 * @param soneLockedEvent
980 public void soneLocked(SoneLockedEvent soneLockedEvent) {
981 final Sone sone = soneLockedEvent.sone();
982 ScheduledFuture<?> tickerObject = ticker.schedule(new Runnable() {
985 @SuppressWarnings("synthetic-access")
987 lockedSonesNotification.add(sone);
988 notificationManager.addNotification(lockedSonesNotification);
990 }, 5, TimeUnit.MINUTES);
991 lockedSonesTickerObjects.put(sone, tickerObject);
995 * Notifies the web interface that a Sone was unlocked.
997 * @param soneUnlockedEvent
1001 public void soneUnlocked(SoneUnlockedEvent soneUnlockedEvent) {
1002 lockedSonesNotification.remove(soneUnlockedEvent.sone());
1003 lockedSonesTickerObjects.remove(soneUnlockedEvent.sone()).cancel(false);
1007 * Notifies the web interface that a {@link Sone} is being inserted.
1009 * @param soneInsertingEvent
1013 public void soneInserting(SoneInsertingEvent soneInsertingEvent) {
1014 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertingEvent.sone());
1015 soneInsertNotification.set("soneStatus", "inserting");
1016 if (soneInsertingEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1017 notificationManager.addNotification(soneInsertNotification);
1022 * Notifies the web interface that a {@link Sone} was inserted.
1024 * @param soneInsertedEvent
1028 public void soneInserted(SoneInsertedEvent soneInsertedEvent) {
1029 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertedEvent.sone());
1030 soneInsertNotification.set("soneStatus", "inserted");
1031 soneInsertNotification.set("insertDuration", soneInsertedEvent.insertDuration() / 1000);
1032 if (soneInsertedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1033 notificationManager.addNotification(soneInsertNotification);
1038 * Notifies the web interface that a {@link Sone} insert was aborted.
1040 * @param soneInsertAbortedEvent
1044 public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
1045 TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
1046 soneInsertNotification.set("soneStatus", "insert-aborted");
1047 soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
1048 if (soneInsertAbortedEvent.sone().getOptions().isSoneInsertNotificationEnabled()) {
1049 notificationManager.addNotification(soneInsertNotification);
1054 * Notifies the web interface that a new Sone version was found.
1056 * @param updateFoundEvent
1060 public void updateFound(UpdateFoundEvent updateFoundEvent) {
1061 newVersionNotification.set("latestVersion", updateFoundEvent.version());
1062 newVersionNotification.set("latestEdition", updateFoundEvent.latestEdition());
1063 newVersionNotification.set("releaseTime", updateFoundEvent.releaseTime());
1064 newVersionNotification.set("disruptive", updateFoundEvent.disruptive());
1065 notificationManager.addNotification(newVersionNotification);
1069 * Notifies the web interface that an image insert was started
1071 * @param imageInsertStartedEvent
1075 public void imageInsertStarted(ImageInsertStartedEvent imageInsertStartedEvent) {
1076 insertingImagesNotification.add(imageInsertStartedEvent.image());
1077 notificationManager.addNotification(insertingImagesNotification);
1081 * Notifies the web interface that an {@link Image} insert was aborted.
1083 * @param imageInsertAbortedEvent
1087 public void imageInsertAborted(ImageInsertAbortedEvent imageInsertAbortedEvent) {
1088 insertingImagesNotification.remove(imageInsertAbortedEvent.image());
1092 * Notifies the web interface that an {@link Image} insert is finished.
1094 * @param imageInsertFinishedEvent
1098 public void imageInsertFinished(ImageInsertFinishedEvent imageInsertFinishedEvent) {
1099 insertingImagesNotification.remove(imageInsertFinishedEvent.image());
1100 insertedImagesNotification.add(imageInsertFinishedEvent.image());
1101 notificationManager.addNotification(insertedImagesNotification);
1105 * Notifies the web interface that an {@link Image} insert has failed.
1107 * @param imageInsertFailedEvent
1111 public void imageInsertFailed(ImageInsertFailedEvent imageInsertFailedEvent) {
1112 insertingImagesNotification.remove(imageInsertFailedEvent.image());
1113 imageInsertFailedNotification.add(imageInsertFailedEvent.image());
1114 notificationManager.addNotification(imageInsertFailedNotification);