[jboss-svn-commits] JBL Code SVN: r10791 - in labs/jbossforums/branches/forums101P22/forums/src: main/org/jboss/portlet/forums/impl and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Apr 5 21:15:29 EDT 2007
Author: unibrew
Date: 2007-04-05 21:15:28 -0400 (Thu, 05 Apr 2007)
New Revision: 10791
Modified:
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsConstants.java
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java
labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
Log:
[JBFORUMS-202] I added support for handling linked type e-mails and no notification for NotificationEngine.
Modified: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsConstants.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsConstants.java 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsConstants.java 2007-04-06 01:15:28 UTC (rev 10791)
@@ -919,6 +919,11 @@
* When a notification message is sent, send the message content.
*/
int WATCH_MODE_EMBEDED = 1;
+
+ /**
+ * Constant saying that watched don't want to be notified by e-mail.
+ */
+ int WATCH_MODE_NONE = 2;
/**
* DOCUMENT_ME
Modified: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-04-06 01:15:28 UTC (rev 10791)
@@ -589,7 +589,7 @@
* @param poster
* @param topic
*/
- void createWatch(Poster poster, Topic topic) throws ModuleException;
+ void createWatch(Poster poster, Topic topic, int mode) throws ModuleException;
/**
* @param topicWatchID
Modified: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-04-06 01:15:28 UTC (rev 10791)
@@ -1731,7 +1731,7 @@
}
}
- public void createWatch(Poster poster, Topic topic)
+ public void createWatch(Poster poster, Topic topic,int mode)
throws ModuleException
{
try
@@ -1751,6 +1751,7 @@
TopicWatch topicWatch = new TopicWatchImpl();
topicWatch.setPoster(poster);
topicWatch.setTopic(topic);
+ topicWatch.setMode(mode);
session.save(topicWatch);
}
catch (HibernateException e)
Modified: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java 2007-04-06 01:15:28 UTC (rev 10791)
@@ -26,6 +26,7 @@
import org.jboss.portlet.forums.ui.Constants;
import org.jboss.portlet.forums.ui.JSFUtil;
import org.jboss.portlet.forums.ui.PortalUtil;
+import org.jboss.portlet.forums.ForumsConstants;
/**
* This controller is used for activating/deactivating topic watches
@@ -77,7 +78,7 @@
//activate the watch for the selected topic
- getForumsModule().createWatch(PortalUtil.getPoster(),topic);
+ getForumsModule().createWatch(PortalUtil.getPoster(),topic,ForumsConstants.WATCH_MODE_EMBEDED);
}
catch(Exception e)
Modified: labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java 2007-04-06 01:15:28 UTC (rev 10791)
@@ -252,14 +252,33 @@
+ "<a href=\""+viewURL.toString() + "\">" + viewURL.toString() + "</a>\n"
+ "<br /><br />\n"
+ bundle.getString("EMAIL_REPLY") + " : "
- + "<a href=\""+replyURL.toString() + "\">" + replyURL.toString() + "</a>";
-
+ + "<a href=\""+replyURL.toString() + "\">" + replyURL.toString() + "</a>"
+ + "<br /><br />\n";
+
+ // For now it is just a copy from embeded mode maybe in future we will differentiate it.
+ String forumLinkedArgsSubject = forumEmbededArgsSubject;
+
+ String forumLinkedArgsText = bundle.getString("EMAIL_LINKED_MODE_INFO")+" <b>"+forum.getName()+"</b> <br /><br />\n"
+ + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
+ + "<a href=\""+viewURL.toString() + "\">" + viewURL.toString() + "</a>\n"
+ + "<br /><br />\n"
+ + bundle.getString("EMAIL_REPLY") + " : "
+ + "<a href=\""+replyURL.toString() + "\">" + replyURL.toString() + "</a>"
+ + "<br /><br />\n";
+
// Notify the forum watchers
for (Iterator i = forum.getWatches().iterator(); i.hasNext();)
{
try
{
Watch watch = (Watch)i.next();
+
+ // If user don't want to be notified by e-mail then continue with next watch.
+ if (watch.getMode()==ForumsConstants.WATCH_MODE_NONE)
+ {
+ continue;
+ }
+
User watcher = watch.getPoster().getUser();
Object watcherId = watcher.getId();
@@ -286,17 +305,18 @@
notifieds.add(watcherId);
String subject = null;
String text = null;
-
- // TODO: LINKED MODE NOT IMPLEMENTED
- //if (watch.getMode() == ForumsConstants.WATCH_MODE_LINKED)
- //{
- //}
- //else
- //{
- subject = forumEmbededArgsSubject;
- text = forumEmbededArgsText;
- //}
+ if (watch.getMode() == ForumsConstants.WATCH_MODE_EMBEDED)
+ {
+ subject = forumEmbededArgsSubject;
+ text = forumEmbededArgsText;
+ }
+ else if (watch.getMode()==ForumsConstants.WATCH_MODE_LINKED)
+ {
+ subject = forumLinkedArgsSubject;
+ text = forumLinkedArgsText;
+ }
+
notify ( watcher, from , subject, text );
}
@@ -312,7 +332,32 @@
log.error("Cannot send an email notification", e);
}
}
-
+
+
+ String topicEmbededArgsSubject = "[" + forum.getName() + "] - "
+ + message.getSubject()
+ + (mode == MODE_REPOST ? " (Repost)" : "");
+
+ String topicEmbededArgsText = out.toString() + "<br /><br />\n"
+ + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
+ + "<a href=\""+viewURL.toString() + "\">" + viewURL.toString() + "</a>\n"
+ + "<br /><br />\n"
+ + bundle.getString("EMAIL_REPLY") + " : "
+ + "<a href=\""+replyURL.toString() + "\">" + replyURL.toString() + "</a>"
+ + "<br /><br />\n";
+
+ // For now it is just a copy from embeded mode maybe in future we will differentiate it.
+ String topicLinkedArgsSubject = topicEmbededArgsSubject;
+
+ String topicLinkedArgsText = bundle.getString("EMAIL_LINKED_MODE_INFO")+": <b>"+topic.getSubject()+"</b><br /><br />\n"
+ + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
+ + "<a href=\""+viewURL.toString() + "\">" + viewURL.toString() + "</a>\n"
+ + "<br /><br />\n"
+ + bundle.getString("EMAIL_REPLY") + " : "
+ + "<a href=\""+replyURL.toString() + "\">" + replyURL.toString() + "</a>"
+ + "<br /><br />\n";
+
+ // Notify the topic watchers
if (mode == MODE_REPLY)
{
// Notify the reply watchers
@@ -321,6 +366,13 @@
try
{
TopicWatch watch = (TopicWatch)i.next();
+
+ // If user don't want to be notified by e-mail then continue with next watch.
+ if (watch.getMode()==ForumsConstants.WATCH_MODE_NONE)
+ {
+ continue;
+ }
+
User watcher = watch.getPoster().getUser();
Object watcherId = watcher.getId();
if (!notifieds.contains(watcherId))
@@ -344,8 +396,21 @@
{
// Authorized
notifieds.add(watcherId);
+ String subject = null;
+ String text = null;
- notify( watcher, from , forumEmbededArgsSubject , forumEmbededArgsText );
+ if (watch.getMode() == ForumsConstants.WATCH_MODE_EMBEDED)
+ {
+ subject = topicEmbededArgsSubject;
+ text = topicEmbededArgsText;
+ }
+ else if (watch.getMode()==ForumsConstants.WATCH_MODE_LINKED)
+ {
+ subject = topicLinkedArgsSubject;
+ text = topicLinkedArgsText;
+ }
+
+ notify( watcher, from , subject , text );
}
else
{
@@ -397,8 +462,8 @@
m.setSentDate(new Date());
buffer = new StringBuffer();
- buffer.append("This message is generated automaticcaly. Please do not reply.<br />\n<br />\n");
buffer.append(text);
+ buffer.append(bundle.getString("EMAIL_FOOTER_MESSAGE"));
m.setContent(buffer.toString(),
"text/html; charset=\"UTF-8\"");
Modified: labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties
===================================================================
--- labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2007-04-06 01:14:26 UTC (rev 10790)
+++ labs/jbossforums/branches/forums101P22/forums/src/resources/portal-forums-war/WEB-INF/classes/ResourceJSF.properties 2007-04-06 01:15:28 UTC (rev 10791)
@@ -2401,7 +2401,8 @@
EMAIL_VIEWORIGINAL=View the original post
EMAIL_STOPWATCHING=Stop watching this topic
EMAIL_REPLY=Reply to the post
-
+EMAIL_LINKED_MODE_INFO=You are receiving this e-mail because you subscribed to
+EMAIL_FOOTER_MESSAGE=This message is generated automaticaly. Please do not reply.
TOPICWATCH_MAIL_1 = You are receiving this email because you are watching this topic. This topic has received a reply since your last visit. You can use the following link to view the replies made.
// BB Code variables
More information about the jboss-svn-commits
mailing list