1 package net.sourceforge.blogentis.plugins.impl;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.util.ArrayList;
26 import java.util.Iterator;
27 import java.util.List;
28
29 import org.apache.commons.lang.StringUtils;
30
31 import net.sourceforge.blogentis.om.Blog;
32 import net.sourceforge.blogentis.om.Comment;
33 import net.sourceforge.blogentis.plugins.AbstractBlogExtensionPoint;
34 import net.sourceforge.blogentis.plugins.IPlugin;
35 import net.sourceforge.blogentis.plugins.base.ICommentExtension;
36 import net.sourceforge.blogentis.plugins.base.ICommentExtensionPoint;
37 import net.sourceforge.blogentis.turbine.BlogRunData;
38
39 /***
40 * Private implementation of the comment extension point.
41 *
42 * @author abas
43 */
44 public class CommentExtensionPointImpl
45 extends AbstractBlogExtensionPoint
46 implements ICommentExtensionPoint {
47 public CommentExtensionPointImpl(IPlugin plugin, Blog blog) {
48 super(plugin, blog);
49 }
50
51 public String getName() {
52 return "Comment Operations Extension Point";
53 }
54
55 public Class getExtensionClass() {
56 return ICommentExtension.class;
57 }
58
59 public boolean commentCreated(BlogRunData data, Comment comment) {
60 boolean status = true;
61 for(Iterator i = extensions.iterator(); i.hasNext();) {
62 ICommentExtension ice = (ICommentExtension)i.next();
63 status = status & ice.commentCreated(data, comment);
64 }
65 return status;
66 }
67
68 public void commentRemoved(BlogRunData data, Comment comment) {
69 for(Iterator i = extensions.iterator(); i.hasNext();) {
70 ICommentExtension ice = (ICommentExtension)i.next();
71 ice.commentRemoved(data, comment);
72 }
73 }
74
75 public List commentActions(BlogRunData data, Comment c) {
76 List results = new ArrayList();
77 for(Iterator i = extensions.iterator(); i.hasNext();) {
78 ICommentExtension ice = (ICommentExtension)i.next();
79 List tmp = ice.commentActions(data, c);
80 if (tmp != null)
81 results.addAll(tmp);
82 }
83 return results;
84 }
85
86 public String getNewCommentMessage(BlogRunData data) {
87 StringBuffer sb = new StringBuffer();
88 for(Iterator i = extensions.iterator(); i.hasNext();) {
89 ICommentExtension ice = (ICommentExtension)i.next();
90 String message = ice.getNewCommentMessage(data);
91 if (!StringUtils.isEmpty(message)) {
92 sb.append(message);
93 if (i.hasNext())
94 sb.append(' ');
95 }
96 }
97 return sb.toString();
98 }
99 }