import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
import net.pterodactylus.sone.core.event.SoneInsertedEvent;
import net.pterodactylus.sone.core.event.SoneInsertingEvent;
import net.pterodactylus.sone.core.event.SoneLockedEvent;
*/
@Override
public void insertAborted(Sone sone, Throwable cause) {
- coreListenerManager.fireSoneInsertAborted(sone, cause);
+ eventBus.post(new SoneInsertAbortedEvent(sone, cause));
}
//
import java.util.EventListener;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.version.Version;
/**
public interface CoreListener extends EventListener {
/**
- * Notifies a listener that the insert of the given Sone was aborted.
- *
- * @see SoneInsertListener#insertAborted(Sone, Throwable)
- * @param sone
- * The Sone that was inserted
- * @param cause
- * The cause for the abortion (may be {@code null})
- */
- public void soneInsertAborted(Sone sone, Throwable cause);
-
- /**
* Notifies a listener that a new version has been found.
*
* @param version
package net.pterodactylus.sone.core;
import net.pterodactylus.sone.data.Image;
-import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.util.event.AbstractListenerManager;
import net.pterodactylus.util.version.Version;
//
/**
- * Notifies all listeners that the insert of the given Sone was aborted.
- *
- * @see SoneInsertListener#insertStarted(Sone)
- * @param sone
- * The Sone being inserted
- * @param cause
- * The cause for the abortion (may be {@code null}
- */
- void fireSoneInsertAborted(Sone sone, Throwable cause) {
- for (CoreListener coreListener : getListeners()) {
- coreListener.soneInsertAborted(sone, cause);
- }
- }
-
- /**
* Notifies all listeners that a new version was found.
*
* @see CoreListener#updateFound(Version, long, long)
--- /dev/null
+/*
+ * Sone - SoneInsertAbortedEvent.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.Sone;
+
+/**
+ * Event that signals that a {@link Sone} insert was aborted.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class SoneInsertAbortedEvent extends SoneEvent {
+
+ /** The cause of the abortion. */
+ private final Throwable cause;
+
+ /**
+ * Creates a new “Sone was inserted” event.
+ *
+ * @param sone
+ * The Sone that was inserted
+ * @param cause
+ * The cause of the abortion
+ */
+ public SoneInsertAbortedEvent(Sone sone, Throwable cause) {
+ super(sone);
+ this.cause = cause;
+ }
+
+ //
+ // ACCESSORS
+ //
+
+ /**
+ * Returns the cause of the abortion.
+ *
+ * @return The cause of the abortion (may be {@code null})
+ */
+ public Throwable cause() {
+ return cause;
+ }
+
+}
import net.pterodactylus.sone.core.event.NewSoneFoundEvent;
import net.pterodactylus.sone.core.event.PostRemovedEvent;
import net.pterodactylus.sone.core.event.PostReplyRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneInsertAbortedEvent;
import net.pterodactylus.sone.core.event.SoneInsertedEvent;
import net.pterodactylus.sone.core.event.SoneInsertingEvent;
import net.pterodactylus.sone.core.event.SoneLockedEvent;
}
}
- //
- // CORELISTENER METHODS
- //
-
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Sone} insert was aborted.
+ *
+ * @param soneInsertAbortedEvent
+ * The event
*/
- @Override
- public void soneInsertAborted(Sone sone, Throwable cause) {
- TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ @Subscribe
+ public void soneInsertAborted(SoneInsertAbortedEvent soneInsertAbortedEvent) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(soneInsertAbortedEvent.sone());
soneInsertNotification.set("soneStatus", "insert-aborted");
- soneInsertNotification.set("insert-error", cause);
- if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ soneInsertNotification.set("insert-error", soneInsertAbortedEvent.cause());
+ if (soneInsertAbortedEvent.sone().getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
notificationManager.addNotification(soneInsertNotification);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/