public void soneUnlocked(Sone sone);
/**
+ * Notifies a listener that the insert of the given Sone has started.
+ *
+ * @see SoneInsertListener#insertStarted(Sone)
+ * @param sone
+ * The Sone that is being inserted
+ */
+ public void soneInserting(Sone sone);
+
+ /**
+ * Notifies a listener that the insert of the given Sone has finished
+ * successfully.
+ *
+ * @see SoneInsertListener#insertFinished(Sone, long)
+ * @param sone
+ * The Sone that has been inserted
+ * @param insertDuration
+ * The insert duration (in milliseconds)
+ */
+ public void soneInserted(Sone sone, long insertDuration);
+
+ /**
+ * 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
/** The “Sone rescued” notification. */
private final ListNotification<Sone> sonesRescuedNotification;
+ /** Notifications for sone inserts. */
+ private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
+
/** Sone locked notification ticker objects. */
private final Map<Sone, Object> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap<Sone, Object>());
return Filters.filteredSet(mentionedSones, Sone.LOCAL_SONE_FILTER);
}
+ /**
+ * Returns the Sone insert notification for the given Sone. If no
+ * notification for the given Sone exists, a new notification is created and
+ * cached.
+ *
+ * @param sone
+ * The Sone to get the insert notification for
+ * @return The Sone insert notification
+ */
+ private TemplateNotification getSoneInsertNotification(Sone sone) {
+ synchronized (soneInsertNotifications) {
+ TemplateNotification templateNotification = soneInsertNotifications.get(sone);
+ if (templateNotification == null) {
+ templateNotification = new TemplateNotification(TemplateParser.parse(createReader("/templates/notify/soneInsertNotification.html")));
+ templateNotification.set("sone", sone);
+ soneInsertNotifications.put(sone, templateNotification);
+ }
+ return templateNotification;
+ }
+ }
+
//
// CORELISTENER METHODS
//
* {@inheritDoc}
*/
@Override
+ public void soneInserting(Sone sone) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ soneInsertNotification.set("soneStatus", "inserting");
+ notificationManager.addNotification(soneInsertNotification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void soneInserted(Sone sone, long insertDuration) {
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ soneInsertNotification.set("soneStatus", "inserted");
+ soneInsertNotification.set("insertDuration", insertDuration / 1000);
+ notificationManager.addNotification(soneInsertNotification);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void soneInsertAborted(Sone sone, Throwable cause) {
+ notificationManager.addNotification(getSoneInsertNotification(sone).set("soneStatus", "insert-aborted").set("insert-error", cause));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public void updateFound(Version version, long releaseTime, long latestEdition) {
newVersionNotification.getTemplateContext().set("latestVersion", version);
newVersionNotification.getTemplateContext().set("latestEdition", latestEdition);
--- /dev/null
+<%if soneStatus|match value="inserting">
+ Your Sone <a href="viewSone.html?sone=<%sone.id|html>"><%sone.niceName|html></a> is now being inserted.
+<%elseif soneStatus|match value="inserted">
+ Your Sone <a href="viewSone.html?sone=<%sone.id|html>"><%sone.niceName|html></a> has been inserted in <%= Notification.SoneInsert.Duration|l10n 0=insertDuration>.
+<%elseif soneStatus|match value="insert-aborted">
+ Inserting your Sone <a href="viewSone.html?sone=<%sone.id|html>"><%sone.niceName|html></a> has failed.
+<%/if>
\ No newline at end of file