import net.pterodactylus.sone.core.Options.Option;
import net.pterodactylus.sone.core.Options.OptionWatcher;
import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
+import net.pterodactylus.sone.core.event.ImageInsertFailedEvent;
import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
@Override
public void imageInsertFailed(Image image, Throwable cause) {
logger.log(Level.WARNING, String.format("Image insert failed for %s." + image), cause);
- coreListenerManager.fireImageInsertFailed(image, cause);
+ eventBus.post(new ImageInsertFailedEvent(image, cause));
}
/**
--- /dev/null
+/*
+ * Sone - ImageInsertFailedEvent.java - Copyright © 2013 David Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.core.event;
+
+import net.pterodactylus.sone.data.Image;
+
+/**
+ * Event that signals that an {@link Image} insert has failed.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class ImageInsertFailedEvent extends ImageEvent {
+
+ /** The cause of the insert failure. */
+ private final Throwable cause;
+
+ /**
+ * Creates a new “image insert failed” event.
+ *
+ * @param image
+ * The image whose insert failed
+ * @param cause
+ * The cause of the insert failure
+ */
+ public ImageInsertFailedEvent(Image image, Throwable cause) {
+ super(image);
+ this.cause = cause;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the cause of the insert failure.
+ *
+ * @return The cause of the insert failure
+ */
+ public Throwable cause() {
+ return cause;
+ }
+
+}
import java.util.logging.Logger;
import net.pterodactylus.sone.core.Core;
-import net.pterodactylus.sone.core.CoreListener;
import net.pterodactylus.sone.core.event.ImageInsertAbortedEvent;
+import net.pterodactylus.sone.core.event.ImageInsertFailedEvent;
import net.pterodactylus.sone.core.event.ImageInsertFinishedEvent;
import net.pterodactylus.sone.core.event.ImageInsertStartedEvent;
import net.pterodactylus.sone.core.event.MarkPostKnownEvent;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
-public class WebInterface implements CoreListener {
+public class WebInterface {
/** The logger. */
private static final Logger logger = Logging.getLogger(WebInterface.class);
notificationManager.addNotification(insertedImagesNotification);
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that an {@link Image} insert has failed.
+ *
+ * @param imageInsertFailedEvent
+ * The event
*/
- @Override
- public void imageInsertFailed(Image image, Throwable cause) {
- insertingImagesNotification.remove(image);
- imageInsertFailedNotification.add(image);
+ @Subscribe
+ public void imageInsertFailed(ImageInsertFailedEvent imageInsertFailedEvent) {
+ insertingImagesNotification.remove(imageInsertFailedEvent.image());
+ imageInsertFailedNotification.add(imageInsertFailedEvent.image());
notificationManager.addNotification(imageInsertFailedNotification);
}