[prev in list] [next in list] [prev in thread] [next in thread]
List: jboss-cvs-commits
Subject: [jboss-cvs] jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors FloodControlIntercept
From: Thomas Heute <theute () users ! sourceforge ! net>
Date: 2005-01-31 20:43:13
Message-ID: E1CviO9-0004yz-HP () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]
User: theute
Date: 05/01/31 12:43:12
Modified: forums/src/main/org/jboss/portlet/forums/interceptors
FloodControlInterceptor.java
NotificationInterceptor.java IndexInterceptor.java
Log:
* Email confirmation for new users
* Email forum notification
* New security mechanism for forums
* Interceptor command filtering is using JBossActionRequest and response
Revision Changes Path
1.2 +5 -3 \
jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java
Index: FloodControlInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/FloodControlInterceptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FloodControlInterceptor.java 14 Jan 2005 23:12:47 -0000 1.1
+++ FloodControlInterceptor.java 31 Jan 2005 20:43:12 -0000 1.2
@@ -12,12 +12,14 @@
import java.util.Date;
-import org.jboss.portal.common.command.AbstractCommandFilter;
import org.jboss.portal.common.command.Command;
import org.jboss.portal.common.command.CommandException;
import org.jboss.portal.common.command.result.Result;
import org.jboss.portal.core.model.User;
import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.core.portlet.AbstractCommandFilter;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.forums.commands.CommandConstants;
import org.jboss.portlet.forums.commands.post.ForumCommand;
@@ -41,7 +43,7 @@
*
* @throws CommandException DOCUMENT_ME
*/
- public Result filter(Command cmd)
+ public Result filter(JBossActionRequest request, JBossActionResponse response, \
Command cmd) throws CommandException
{
if (cmd instanceof ForumCommand)
@@ -77,7 +79,7 @@
}
}
- return getNext().filter(cmd);
+ return getNext().filter(request, response, cmd);
}
/**
1.6 +323 -431 \
jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java
Index: NotificationInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- NotificationInterceptor.java 28 Jan 2005 11:43:51 -0000 1.5
+++ NotificationInterceptor.java 31 Jan 2005 20:43:12 -0000 1.6
@@ -19,39 +19,35 @@
import javax.management.MBeanServer;
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import javax.servlet.ServletException;
+import javax.portlet.PortletURL;
import javax.transaction.UserTransaction;
-import net.sf.hibernate.HibernateException;
-import net.sf.hibernate.Session;
-
-import org.jboss.hibernate.session.HibernateContext;
-import org.jboss.portal.common.command.AbstractCommandFilter;
import org.jboss.portal.common.command.Command;
import org.jboss.portal.common.command.CommandException;
import org.jboss.portal.common.command.result.Result;
-import org.jboss.portal.common.context.DelegateContext;
import org.jboss.portal.common.transaction.NestedException;
import org.jboss.portal.common.transaction.TransactionException;
import org.jboss.portal.common.transaction.Transactions;
import org.jboss.portal.common.util.Tools;
-import org.jboss.portal.core.impl.user.UserModuleImpl;
import org.jboss.portal.core.model.User;
import org.jboss.portal.core.modules.MailModule;
import org.jboss.portal.core.modules.ModuleConstants;
import org.jboss.portal.core.modules.ModuleException;
-import org.jboss.portal.core.modules.UserModule;
+import org.jboss.portal.core.portlet.AbstractCommandFilter;
import org.jboss.portal.core.security.AuthorizationRealm;
import org.jboss.portal.format.render.bbcodehtml.ToTextRenderer;
import org.jboss.portal.format.template.TemplateLoader;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
+import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.forums.ForumsConstants;
import org.jboss.portlet.forums.ForumsModule;
+import org.jboss.portlet.forums.ForumsPortlet;
import org.jboss.portlet.forums.commands.CommandConstants;
import org.jboss.portlet.forums.commands.post.NewTopicCommand;
import org.jboss.portlet.forums.commands.post.ReplyCommand;
import org.jboss.portlet.forums.commands.post.RepostCommand;
import org.jboss.portlet.forums.impl.ForumsModuleImpl;
-import org.jboss.portlet.forums.impl.PostImpl;
import org.jboss.portlet.forums.model.Category;
import org.jboss.portlet.forums.model.Forum;
import org.jboss.portlet.forums.model.ForumWatch;
@@ -59,498 +55,394 @@
import org.jboss.portlet.forums.model.Post;
import org.jboss.portlet.forums.model.Poster;
import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.TopicWatch;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*/
-public class NotificationInterceptor extends AbstractCommandFilter
+public class NotificationInterceptor
+ extends AbstractCommandFilter
{
- private static final int MODE_POST = 0;
- private static final int MODE_REPLY = 1;
+ private static final int MODE_POST = 0;
+
+ private static final int MODE_REPLY = 1;
+
private static final int MODE_REPOST = 2;
-
- private ForumsModule forumsModule;
- private MBeanServer server;
- private TemplateLoader mailTemplates;
- private String from = "portal@jbossportal.org";
- private boolean allowReplyViaEmail;
- private String replyURLBase = "";
- private String viewURLBase = "";
- private AuthorizationRealm authRealm;
- private QueuedExecutor executor;
- private InitialContext ctx;
- private MailModule mailModule;
- private ResourceBundle bundle;
-
-
- public NotificationInterceptor(ForumsModule module)
- {
- this.forumsModule = module;
- try
- {
- mailModule = (MailModule) new \
InitialContext().lookup(ModuleConstants.MAILMODULE_JNDINAME);
- }
- catch (NamingException e)
- {
- e.printStackTrace();
- }
- }
-
-
- public void start() throws Exception
- {
- executor = new QueuedExecutor(new LinkedQueue());
- try
- {
- ctx = new InitialContext();
- }
- catch (NamingException e)
- {
- throw new Exception(e);
- }
+ private ForumsModule forumsModule;
- }
- public void stop()
- {
- executor.shutdownAfterProcessingCurrentTask();
- executor = null;
- }
- public String getFrom()
- {
- return from;
- }
- public void setFrom(String from)
- {
- this.from = from;
- }
- public boolean getAllowReplyViaEmail()
- {
- return allowReplyViaEmail;
- }
- public void setAllowReplyViaEmail(boolean allowReply)
- {
- allowReplyViaEmail = allowReply;
- }
-
- public MBeanServer getServer()
- {
- return server;
- }
- public void setServer(MBeanServer server)
- {
- this.server = server;
- }
+ private MBeanServer server;
- public String getReplyURLBase()
- {
- return replyURLBase;
- }
-
- public void setReplyURLBase(String replyURLBase)
+ private TemplateLoader mailTemplates;
+
+ private String from;
+
+ private AuthorizationRealm authRealm;
+
+ private QueuedExecutor executor;
+
+ private InitialContext ctx;
+
+ private MailModule mailModule;
+
+ private JBossPortlet portlet;
+
+ public NotificationInterceptor(JBossPortlet portlet, ForumsModule module)
+ {
+ this.portlet = portlet;
+ this.forumsModule = module;
+ try
{
- this.replyURLBase = replyURLBase;
+ mailModule = (MailModule) new InitialContext()
+ .lookup(ModuleConstants.MAILMODULE_JNDINAME);
}
-
- public String getViewURLBase()
+ catch (NamingException e)
{
- return viewURLBase;
+ e.printStackTrace();
}
-
- public void setViewURLBase(String viewURLBase)
+ executor = new QueuedExecutor(new LinkedQueue());
+ try
{
- this.viewURLBase = viewURLBase;
+ ctx = new InitialContext();
}
-
- public TemplateLoader getMailTemplates()
+ catch (NamingException e)
{
- return mailTemplates;
+ e.printStackTrace();
}
-
- public Result filter(Command cmd) throws CommandException
+ }
+
+ public void stop()
+ {
+ executor.shutdownAfterProcessingCurrentTask();
+ executor = null;
+ }
+
+ public void setFrom(String from)
+ {
+ this.from = from;
+ }
+
+ public MBeanServer getServer()
+ {
+ return server;
+ }
+
+ public void setServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ public TemplateLoader getMailTemplates()
+ {
+ return mailTemplates;
+ }
+
+ public Result filter(final JBossActionRequest request,
+ final JBossActionResponse response, Command cmd)
+ throws CommandException
+ {
+ Result result = null;
+ try
{
- Result result = null;
- // try
- // {
- result = getNext().filter(cmd);
-
- if (result.getType() == CommandConstants.TYPE_REPLY_POSTED)
- {
- /*
- final Post post = ((ReplyCommand)cmd).newPost;
- Notification notif = new Notification(post, MODE_POST);
- notif.run();
- */
- /*
- executor.execute(new java.lang.Runnable()
- {
- public void run()
- {
- schedule(post, MODE_REPLY);
- }
- });
- */
- }
- else if (result.getType() == \
CommandConstants.TYPE_NEW_TOPIC_POSTED) + result = getNext().filter(request, \
response, cmd); +
+ if (result.getType() == CommandConstants.TYPE_REPLY_POSTED)
+ {
+ final Post post = ((ReplyCommand) cmd).newPost;
+ executor.execute(new java.lang.Runnable()
+ {
+ public void run()
{
- final Post post = ((NewTopicCommand)cmd).post;
- try
- {
- executor.execute(new java.lang.Runnable()
- {
- public void run()
- {
- schedule(post, MODE_REPLY);
- }
- });
- }
- catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ schedule(request, response, post, MODE_REPLY);
}
- else if (result.getType() == CommandConstants.TYPE_REPOSTED)
- {/*
- final Post post = ((RepostCommand)cmd).post;
- executor.execute(new java.lang.Runnable()
- {
- public void run()
- {
- schedule(post, MODE_REPOST);
- }
- });
- */
- }
- /*
- }
- catch(InterruptedException ignore)
- {
- ignore.printStackTrace();
+ });
}
- */
- return result;
- }
-
- private void schedule(final Post post, int mode)
- {
- try
+ else if (result.getType() == CommandConstants.TYPE_NEW_TOPIC_POSTED)
{
- executor.execute(new Runnable()
+ final Post post = ((NewTopicCommand) cmd).post;
+ executor.execute(new java.lang.Runnable()
{
public void run()
{
- UserTransaction tx;
- try
- {
- tx = (UserTransaction)ctx.lookup("UserTransaction");
- Notification notif = new Notification(post.getID(), \
MODE_POST);
- Transactions.requiresNew(tx, notif);
- }
- catch (NamingException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (NestedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- catch (TransactionException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ schedule(request, response, post, MODE_POST);
}
});
}
- catch (InterruptedException e)
+ else if (result.getType() == CommandConstants.TYPE_REPOSTED)
{
- e.printStackTrace();
+ final Post post = ((RepostCommand) cmd).post;
+ executor.execute(new java.lang.Runnable()
+ {
+ public void run()
+ {
+ schedule(request, response, post, MODE_REPOST);
+ }
+ });
}
}
+ catch (InterruptedException e)
+ {
+ throw new CommandException();
+ }
+
+ return result;
+ }
- private Object[] aaa(Post post)
+ private void schedule(final JBossActionRequest request,
+ final JBossActionResponse response, final Post post, final int mode)
+ {
+ try
{
- Topic topic = post.getTopic();
- DelegateContext root = new DelegateContext();
- root.put("EMAIL_SIG", "");
- root.put("SITENAME", ""); \
//api.getConfigVar(Constants.CFG_SITENAME).toString());
- root.put("TOPIC_TITLE", topic.getSubject());
- root.put("U_TOPIC", viewURLBase + "&p=" + post.getID() + "#" + \
post.getID());
- root.put("U_STOP_WATCHING_TOPIC", viewURLBase + "&t=" + topic.getId() + \
"&unwatch=topic");
- return new Object[] {
- null,
- null,
- getTopicReplyNotificationSubject()};
- // topicNotifyTemplate.render(root)};
+ executor.execute(new Runnable()
+ {
+ public void run()
+ {
+ UserTransaction tx;
+ try
+ {
+ tx = (UserTransaction) ctx.lookup("UserTransaction");
+ Notification notif = new Notification(portlet, request, \
response, post + .getID(), mode);
+ Transactions.requiresNew(tx, notif);
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ catch (NestedException e)
+ {
+ e.printStackTrace();
+ }
+ catch (TransactionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
}
- private String getTopicReplyNotificationSubject()
+ catch (InterruptedException e)
{
- return "TEST";
- //return \
api.getResourceBundle(Locale.getDefault()).getString("bb.Topic_reply_notification"); \
+ e.printStackTrace(); }
- private Object[] bbb(Post post)
+ }
+
+ private String getFrom(Post post, User user)
+ {
+ StringBuffer fromBuf = null;
+ if ((post.getPoster().getUser().getGivenName() != null)
+ && (post.getPoster().getUser().getFamilyName() != null))
{
- Forum forum = post.getTopic().getForum();
- DelegateContext root = new DelegateContext();
- root.put("EMAIL_SIG", "");
- root.put("SITENAME", "");
- root.put("FORUM_TITLE", forum.getName());
- root.put("U_POST", viewURLBase + "&p=" + post.getID() + "#" + \
post.getID());
- return new Object[] {
- null,
- null,
- getTopicReplyNotificationSubject()};
- }
-
- private String getFrom(Post post, User user){
- StringBuffer fromBuf = null;
- if ((post.getPoster().getUser().getGivenName() != null) && \
(post.getPoster().getUser().getFamilyName() != null))
- {
- fromBuf
- = new StringBuffer(post.getPoster().getUser().getGivenName() + " " + \
post.getPoster().getUser().getFamilyName() + " <");
- }
- else
- {
- fromBuf
- = new StringBuffer(post.getPoster().getUserName() + " <");
- }
- if (allowReplyViaEmail)
- {
- int at = from.indexOf("@");
- String domain = from.substring(at);
- fromBuf.append(user.getID() + "-" + post.getID() + domain);
- }
- else
- {
- fromBuf.append(from);
- }
-
- fromBuf.append(">");
-
- return fromBuf.toString();
+ fromBuf = new StringBuffer(post.getPoster().getUser().getGivenName()
+ + " " + post.getPoster().getUser().getFamilyName() + " <");
}
-
- private String getMD5HashInfo(User user, Post post)
+ else
{
- String s = user.getUserName() + post.getID() + user.getPassword();
- return Tools.md5AsHexString(s);
+ fromBuf = new StringBuffer(post.getPoster().getUserName() + " <");
}
-
-
+ fromBuf.append(from + ">");
+ return fromBuf.toString();
+ }
+
+ private String getMD5HashInfo(User user, Post post)
+ {
+ String s = user.getUserName() + post.getID() + user.getPassword();
+ return Tools.md5AsHexString(s);
+ }
/**
* A notification job
*/
- class Notification implements Transactions.Runnable
+ class Notification
+ implements Transactions.Runnable
+ {
+ private Post post;
+
+ private int mode;
+
+ private Integer postId;
+
+ private JBossActionRequest request;
+
+ private JBossActionResponse response;
+
+ private JBossPortlet portlet;
+
+ private ResourceBundle bundle;
+
+ Notification(JBossPortlet portlet, final JBossActionRequest request,
+ final JBossActionResponse response, final Integer postId, int mode)
{
- private Post post;
- private int mode;
- private Integer postId;
-
- private UserModule userModule;
-
- Notification(final Integer postId, int mode)
- {
- this.postId = postId;
- /*
-// Session session = \
HibernateContext.getSession("java:portal/SessionFactory");
- ForumsModule forumsModule = new ForumsModuleImpl();
- userModule = new UserModuleImpl();
+ this.mode = mode;
+ this.postId = postId;
+ this.request = request;
+ this.response = response;
+ bundle = portlet.getResourceBundle(request.getLocale());
+ }
- try
- {
-// post = (PostImpl) session.get(PostImpl.class, postId);
- post = forumsModule.findPostByID(postId);
- System.out.println("Topic:" + post.getTopic());
- }
- catch (ModuleException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- */
- this.mode = mode;
-
+ public Object run()
+ {
+ ForumsModule forumsModule = new ForumsModuleImpl();
+ try
+ {
+ post = forumsModule.findPostByID(postId);
}
- public Object run()
+ catch (ModuleException e)
{
-// Session session = \
HibernateContext.getSession("java:portal/SessionFactory");
- ForumsModule forumsModule = new ForumsModuleImpl();
- userModule = new UserModuleImpl();
-
- try
+ e.printStackTrace();
+ }
+ Forum forum = post.getTopic().getForum();
+ Category category = forum.getCategory();
+ Topic topic = post.getTopic();
+ Message message = post.getMessage();
+ String[] test = new String[] { category.getTitle(), forum.getName() };
+ // Hold the notified users to avoid duplicated
+ Set notifieds = new HashSet();
+ try
+ {
+ // If this is not an anonymous post, put the user in the notified list
+ // he won't be notified of his own action
+ User poster = post.getPoster().getUser();
+ if (poster != null)
{
-// post = (PostImpl) session.get(PostImpl.class, postId);
- post = forumsModule.findPostByID(postId);
- System.out.println("Topic:" + post.getTopic());
+ notifieds.add(poster.getID());
}
- catch (ModuleException e)
+
+ char[] chars = message.getText().toCharArray();
+ StringWriter out = new StringWriter();
+ ToTextRenderer renderer = new ToTextRenderer();
+ renderer.setWriter(out);
+ renderer.render(chars, 0, chars.length);
+
+ PortletURL viewURL = response.createRenderURL();
+ viewURL.setParameter("p", post.getID().toString());
+ viewURL.setParameter("op", ForumsPortlet.OP_SHOWTOPIC);
+
+ PortletURL replyURL = response.createActionURL();
+ replyURL.setParameter("op", "posting");
+ replyURL.setParameter("mode", "reply");
+ replyURL.setParameter("p", post.getID().toString());
+
+ String forumEmbededArgsSubject = "[" + forum.getName() + "] - "
+ + message.getSubject()
+ + (mode == MODE_REPOST ? " (Repost)" : "");
+
+ String forumEmbededArgsText = out.toString() + "\n\n"
+ + bundle.getString("EMAIL_VIEWORIGINAL") + " : "
+ + viewURL.toString() + "#" + post.getID() + "\n\n"
+ + bundle.getString("EMAIL_REPLY") + " : "
+ + replyURL.toString();
+ // Notify the forum watchers
+ for (Iterator i = forum.getWatches().iterator(); i.hasNext();)
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ try
+ {
+ ForumWatch watch = (ForumWatch) i.next();
+ Poster watcher = watch.getPoster();
+ Integer watcherId = watcher.getID();
+ if (!notifieds.contains(watcherId))
+ {
+ if (request.hasPermission(test, "ReadForum"))
+ {
+ notifieds.add(watcherId);
+ Object[] args;
+
+ String subject = null;
+ String text = null;
+ if (watch.getMode() == ForumsConstants.WATCH_MODE_LINKED)
+ {
+ }
+ else
+ {
+ subject = forumEmbededArgsSubject;
+ text = forumEmbededArgsText;
+ }
+ mailModule.send(getFrom(post, watcher.getUser()),
+ watcher.getUser().getRealEmail(), subject, text);
+ }
+ else
+ {
+ // Not authorized anymore, we remove the watch
+ forumsModule.removeForumWatch(watch);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot send an email notification", e);
+ }
}
-
- System.out.println("NOTIFICATION.RUN");
-
- Forum forum = post.getTopic().getForum();
- Category category = forum.getCategory();
- Topic topic = post.getTopic();
- Message message = post.getMessage();
- // For the security checks
- // Auth auth = forum.getAuth();
- String test = category.getTitle() + ":" + forum.getName() + ":";
- // Hold the notified users to avoid duplicated
- Set notifieds = new HashSet();
- try
+ if (mode == MODE_REPLY)
{
- // If this is not an anonymous post, put the user in the notified \
list
- // he won't be notified of his own action
- /*User poster = post.getPoster().getUser();
- if (poster != null)
- {
- notifieds.add(poster.getID());
- }*/
- // Compute the body of the message when the user wants a link to \
the post
- Object[] topicLinkedArgs = aaa(post);
- Object[] forumLinkedArgs = bbb(post);
- char[] chars = message.getText().toCharArray();
- StringWriter out = new StringWriter();
- ToTextRenderer renderer = new ToTextRenderer();
- renderer.setWriter(out);
- renderer.render(chars, 0, chars.length);
- String subject = "[" + forum.getName() + "] - " + \
message.getSubject() + (mode == MODE_REPOST ? " (Repost)" : "");
- Object[] forumEmbededArgs = new Object[] {
- null,
- null,
- subject,
- out.toString() + "\n\n" + \
bundle.getString("EMAIL_VIEWORIGINAL")+ " : " + viewURLBase + "&p=" + post.getID() + \
"#" + post.getID() + "\n\n" +
- bundle.getString("EMAIL_REPLY")+ " : " + replyURLBase + "&p=" + \
post.getID()};
- // Notify the forum watchers
- for (Iterator i = forum.getWatches().iterator();i.hasNext();)
+ // Notify the reply watchers
+ for (Iterator i = topic.getWatches().iterator(); i.hasNext();)
{
try
{
- ForumWatch watch = (ForumWatch)i.next();
- Poster watcher = watch.getPoster();
+ TopicWatch watch = (TopicWatch) i.next();
+ User watcher = watch.getPoster().getUser();
Integer watcherId = watcher.getID();
if (!notifieds.contains(watcherId))
{
- //TODO: Security Breach, if you remove the rights to see a \
forum, the user will still have the emails sent to him.
- // Level level = \
module.secGetLevel(watcher.retrieveGroups(), test);
- //if (auth.can(Auth.TYPE_READ, true, level))
- // if (PortletHelper.isAuthorized())
- // {
+ if (request.hasPermission(test, "ReadForum"))
+ {
// Authorized
notifieds.add(watcherId);
- Object[] args;
-
- if (watch.getMode() == \
ForumsConstants.WATCH_MODE_LINKED)
- {
- args = forumLinkedArgs;
- if (allowReplyViaEmail)
- {
- args[2] = getTopicReplyNotificationSubject() + " \
- " + getMD5HashInfo(watcher.getUser(), post);
- }
- }
- else
- {
- args = forumEmbededArgs;
- if (allowReplyViaEmail)
- {
- args[2] = subject + " - " + \
getMD5HashInfo(watcher.getUser(), post);
- }
- }
- args[0] = getFrom(post, watcher.getUser());
- args[1] = watcher.getUser().getRealEmail();
- System.out.println("Send email");
- mailModule.send((String)args[0], \
watcher.getUser().getRealEmail(), (String)args[2], (String)args[3]);
-// server.invoke(name, "send", args, signature);
- // }
- // else
- // {
- // // Not authorized anymore, we remove the watch
- // watch.remove();
- // }
- }
- }
- catch(Exception e)
- {
- log.error("Cannot send an email notification", e);
- }
- }
- /*
- if (mode == MODE_REPLY)
- {
- // Notify the reply watchers
- for (Iterator i = topic.getWatches().iterator();i.hasNext();)
- {
- try
- {
- TopicWatch watch = (TopicWatch)i.next();
- User watcher = watch.getUser();
- Integer watcherId = watcher.getID();
- if (!notifieds.contains(watcherId))
+ PortletURL unwatchTopicURL = response
+ .createActionURL();
+ unwatchTopicURL.setParameter("op", "topic_watches");
+ unwatchTopicURL.setParameter("topicwatch_id", watch
+ .getID().toString());
+
+ String mailBody = bundle
+ .getString("TOPICWATCH_MAIL_1")
+ + "\n\n"
+ + post.getTopic().getSubject()
+ + "\n\n"
+ + bundle.getString("EMAIL_VIEWORIGINAL")
+ + " : "
+ + viewURL.toString()
+ + "#"
+ + post.getID()
+ + "\n\n"
+ + bundle.getString("EMAIL_STOPWATCHING")
+ + " : " + unwatchTopicURL.toString();
+
+ mailModule
+ .send(
+ (String) getFrom(post, watcher),
+ watcher.getRealEmail(),
+ "["
+ + forum.getName()
+ + "] "
+ + bundle
+ \
.getString("Topic_reply_notification"), + \
mailBody); + }
+ else
{
- Level level = \
module.secGetLevel(watcher.retrieveGroups(), test);
- if (auth.can(Auth.TYPE_READ, true, level))
- {
- // Authorized
- notifieds.add(watcherId);
- topicLinkedArgs[0] = getFrom(post, watcher);
- topicLinkedArgs[1] = watcher.getRealEmail();
- if (allowReplyViaEmail)
- {
- topicLinkedArgs[2] = \
getTopicReplyNotificationSubject() + " - " + getMD5HashInfo(watcher, \
post);
- }
-
- server.invoke(name, "send", topicLinkedArgs, \
signature);
- }
- else
- {
- // Not authorized anymore, we remove the watch
- watch.remove();
- }
+ // Not authorized anymore, we remove the watch
+ forumsModule.removeTopicWatch(watch);
}
}
- catch(Exception e)
- {
- log.error("Cannot send email notification", e);
- }
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot send email notification", e);
}
}
- */
- }
- catch (IllegalArgumentException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
}
-
- return null;
}
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ return null;
}
- /**
- * @return Returns the bundle.
- */
- public ResourceBundle getBundle()
- {
- return bundle;
- }
- /**
- * @param bundle The bundle to set.
- */
- public void setBundle(ResourceBundle bundle)
- {
- this.bundle = bundle;
- }
-}
+ }
+}
\ No newline at end of file
1.3 +5 -3 \
jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java
Index: IndexInterceptor.java
===================================================================
RCS file: /cvsroot/jboss/jboss-portal/forums/src/main/org/jboss/portlet/forums/interceptors/IndexInterceptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- IndexInterceptor.java 15 Jan 2005 17:57:40 -0000 1.2
+++ IndexInterceptor.java 31 Jan 2005 20:43:12 -0000 1.3
@@ -10,14 +10,16 @@
*****************************************/
package org.jboss.portlet.forums.interceptors;
-import org.jboss.portal.common.command.AbstractCommandFilter;
import org.jboss.portal.common.command.Command;
import org.jboss.portal.common.command.CommandException;
import org.jboss.portal.common.command.result.Result;
+import org.jboss.portal.core.portlet.AbstractCommandFilter;
+import org.jboss.portlet.JBossActionRequest;
+import org.jboss.portlet.JBossActionResponse;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class IndexInterceptor
extends AbstractCommandFilter // implements IndexConstants
@@ -33,7 +35,7 @@
return index;
}
*/
- public Result filter(Command cmd)
+ public Result filter(JBossActionRequest request, JBossActionResponse response, \
Command cmd) throws CommandException
{
/* Result result = getNext().filter(cmd);
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic