projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert “Sone insert was aborted” into EventBus-based event.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
WebInterface.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/WebInterface.java
b/src/main/java/net/pterodactylus/sone/web/WebInterface.java
index
4534c35
..
7c16c09
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
+++ b/
src/main/java/net/pterodactylus/sone/web/WebInterface.java
@@
-45,7
+45,12
@@
import net.pterodactylus.sone.core.event.NewPostReplyFoundEvent;
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.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;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
import net.pterodactylus.sone.core.event.SoneRemovedEvent;
+import net.pterodactylus.sone.core.event.SoneUnlockedEvent;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Image;
import net.pterodactylus.sone.data.Post;
@@
-936,15
+941,15
@@
public class WebInterface implements CoreListener {
}
}
}
}
- //
- // CORELISTENER METHODS
- //
-
/**
/**
- * {@inheritDoc}
+ * Notifies the web interface that a Sone was locked.
+ *
+ * @param soneLockedEvent
+ * The event
*/
*/
- @Override
- public void soneLocked(final Sone sone) {
+ @Subscribe
+ public void soneLocked(SoneLockedEvent soneLockedEvent) {
+ final Sone sone = soneLockedEvent.sone();
Object tickerObject = Ticker.getInstance().registerEvent(System.currentTimeMillis() + (5 * 60) * 1000, new Runnable() {
@Override
Object tickerObject = Ticker.getInstance().registerEvent(System.currentTimeMillis() + (5 * 60) * 1000, new Runnable() {
@Override
@@
-959,52
+964,68
@@
public class WebInterface implements CoreListener {
}
/**
}
/**
- * {@inheritDoc}
+ * Notifies the web interface that a Sone was unlocked.
+ *
+ * @param soneUnlockedEvent
+ * The event
*/
*/
- @
Overrid
e
- public void soneUnlocked(Sone
sone
) {
- lockedSonesNotification.remove(sone);
- Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(sone));
+ @
Subscrib
e
+ public void soneUnlocked(Sone
UnlockedEvent soneUnlockedEvent
) {
+ lockedSonesNotification.remove(sone
UnlockedEvent.sone()
);
+ Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(sone
UnlockedEvent.sone()
));
}
/**
}
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Sone} is being inserted.
+ *
+ * @param soneInsertingEvent
+ * The event
*/
*/
- @
Overrid
e
- public void soneInserting(Sone
sone
) {
- TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ @
Subscrib
e
+ public void soneInserting(Sone
InsertingEvent soneInsertingEvent
) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone
InsertingEvent.sone()
);
soneInsertNotification.set("soneStatus", "inserting");
soneInsertNotification.set("soneStatus", "inserting");
- if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ if (sone
InsertingEvent.sone()
.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
notificationManager.addNotification(soneInsertNotification);
}
}
/**
notificationManager.addNotification(soneInsertNotification);
}
}
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Sone} was inserted.
+ *
+ * @param soneInsertedEvent
+ * The event
*/
*/
- @
Overrid
e
- public void soneInserted(Sone
sone, long insertDuration
) {
- TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ @
Subscrib
e
+ public void soneInserted(Sone
InsertedEvent soneInsertedEvent
) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone
InsertedEvent.sone()
);
soneInsertNotification.set("soneStatus", "inserted");
soneInsertNotification.set("soneStatus", "inserted");
- soneInsertNotification.set("insertDuration",
insertDuration
/ 1000);
- if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ soneInsertNotification.set("insertDuration",
soneInsertedEvent.insertDuration()
/ 1000);
+ if (sone
InsertedEvent.sone()
.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
notificationManager.addNotification(soneInsertNotification);
}
}
/**
notificationManager.addNotification(soneInsertNotification);
}
}
/**
- * {@inheritDoc}
+ * Notifies the web interface that a {@link Sone} insert was aborted.
+ *
+ * @param soneInsertAbortedEvent
+ * The event
*/
*/
- @
Overrid
e
- public void soneInsertAborted(Sone
sone, Throwable cause
) {
- TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ @
Subscrib
e
+ public void soneInsertAborted(Sone
InsertAbortedEvent soneInsertAbortedEvent
) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone
InsertAbortedEvent.sone()
);
soneInsertNotification.set("soneStatus", "insert-aborted");
soneInsertNotification.set("soneStatus", "insert-aborted");
- soneInsertNotification.set("insert-error",
cause
);
- if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ soneInsertNotification.set("insert-error",
soneInsertAbortedEvent.cause()
);
+ if (sone
InsertAbortedEvent.sone()
.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
notificationManager.addNotification(soneInsertNotification);
}
}
notificationManager.addNotification(soneInsertNotification);
}
}
+ //
+ // CORELISTENER METHODS
+ //
+
/**
* {@inheritDoc}
*/
/**
* {@inheritDoc}
*/