Author: shane.bryzak(a)jboss.com
Date: 2010-07-27 04:58:14 -0400 (Tue, 27 Jul 2010)
New Revision: 13515
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java
Modified:
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml
Log:
more spam report enhancements, preparation for user nuke feature
Modified: branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/etc/i18n/messages_en.properties 2010-07-27
08:58:14 UTC (rev 13515)
@@ -169,6 +169,8 @@
lacewiki.label.WriteProtected=Restrict edit access to admins
lacewiki.label.User=User
lacewiki.label.AreYouSureYouWantToDelete=Are you sure you want to delete
+lacewiki.label.AreYouSureYouWantToNukePrefix=WARNING!!! Are you sure you want to nuke
user
+lacewiki.label.AreYouSureYouWantToNukeSuffix=\'s ass? This action is typically
reserved for spammers who desecrate our beloved site. If you click the OK button, this
user's account, posts and comments will all be deleted, and their e-mail address and
IP address blacklisted. Also, an inter-continental ballistic missile carrying a million
rabid fleas will be launched at their home address.
lacewiki.label.Confirmation=Confirmation
lacewiki.label.AreYouSureYouWantToExecute=Are you sure you want to execute this
operation?
@@ -374,6 +376,7 @@
lacewiki.button.adminHome.Preferences=P<u>r</u>eferences
lacewiki.button.adminHome.Preferences.accesskey=R
lacewiki.button.adminHome.SpamReport=Spam Reports
+
lacewiki.button.adminHome.SaveSettings=<u>S</u>ave Settings
lacewiki.button.adminHome.SaveSettings.accesskey=S
lacewiki.label.adminHome.SearchIndex=Search Index
@@ -387,6 +390,7 @@
lacewiki.label.adminHome.spamReport.Reporter=Reporter
lacewiki.label.adminHome.spamReport.Comment=Comment
lacewiki.label.adminHome.spamReport.Poster=Comment Poster
+lacewiki.label.adminHome.spamReport.ViewOriginal=View the original post
lacewiki.label.adminHome.TargetWithPlaceHolder=Target with [[link]] placeholder
lacewiki.label.adminHome.NotAvailableForSkin=Administration is not available with this
skin.
@@ -447,6 +451,7 @@
lacewiki.button.userHome.SaveSettings.accesskey=S
lacewiki.button.userHome.Delete=<u>D</u>elete
lacewiki.button.userHome.Delete.accesskey=D
+lacewiki.button.userHome.Nuke=Nuke Their Ass
lacewiki.label.userHome.NotAvailableForSkin=User management is not available with this
skin.
lacewiki.msg.userHome.PortraitRemoved=The portrait has been removed, save to make changes
permanent.
lacewiki.msg.userHome.WrongPortraitImageType=The file type '{0}' is not
supported, the portrait was not updated.
Modified:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/connectors/feed/RomeFeedConnector.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -6,29 +6,31 @@
*/
package org.jboss.seam.wiki.connectors.feed;
-import com.sun.syndication.feed.synd.SyndContent;
-import com.sun.syndication.feed.synd.SyndEntry;
-import com.sun.syndication.feed.synd.SyndFeed;
-import com.sun.syndication.io.FeedException;
-import com.sun.syndication.io.SyndFeedInput;
-import com.sun.syndication.io.XmlReader;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.*;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.wiki.core.model.Feed;
-import org.jboss.seam.wiki.core.model.FeedEntry;
-
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
import java.net.URL;
-import java.net.SocketTimeoutException;
-import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import sun.net.www.protocol.http.HttpURLConnection;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.model.Feed;
+import org.jboss.seam.wiki.core.model.FeedEntry;
+import com.sun.syndication.feed.synd.SyndContent;
+import com.sun.syndication.feed.synd.SyndEntry;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+
/**
*
* TODO: This requires a system property for timeout:
sun.net.client.defaultConnectTimeout=30000
Modified:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentHome.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -20,6 +20,7 @@
import org.jboss.seam.wiki.core.feeds.FeedEntryManager;
import org.jboss.seam.wiki.core.model.*;
import org.jboss.seam.wiki.core.action.prefs.CommentsPreferences;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import org.jboss.seam.wiki.core.ui.WikiRedirect;
import org.jboss.seam.wiki.core.wikitext.editor.WikiTextEditor;
@@ -42,6 +43,9 @@
@In
protected FeedDAO feedDAO;
+
+ @In
+ protected SpamReportDAO spamReportDAO;
@In("#{preferences.get('Comments')}")
protected CommentsPreferences commentsPreferences;
@@ -176,6 +180,8 @@
feedDAO.findFeeds(getInstance()),
feedDAO.findFeedEntry(getInstance())
);
+
+ spamReportDAO.removeReports(spamReportDAO.findReports(getInstance()));
remove();
getEntityManager().clear();
Modified:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/CommentNodeRemover.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -37,5 +37,7 @@
feedDAO.findFeeds(comment),
feedDAO.findFeedEntry(comment)
);
+
+ spamReportDAO.removeReports(spamReportDAO.findReports(comment));
}
}
\ No newline at end of file
Modified:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/NodeRemover.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -11,6 +11,7 @@
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.dao.SpamReportDAO;
import org.jboss.seam.wiki.core.dao.UserDAO;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.feeds.FeedDAO;
@@ -32,6 +33,9 @@
@In
protected FeedDAO feedDAO;
+
+ @In
+ protected SpamReportDAO spamReportDAO;
@In
protected WikiNodeDAO wikiNodeDAO;
Modified:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-27
08:32:39 UTC (rev 13514)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -353,7 +353,26 @@
}
return outcome;
}
+
+ @Restrict("#{s:hasPermission('User', 'delete',
userHome.instance)}")
+ public String nuke() {
+ // TODO need to do almost the same as remove(), however we want to delete
+ // all the user's nodes instead of re-parenting them, plus add their
+ // e-mail and ip address to the blacklist
+
+ // Remove preferences for this user
+ PreferenceProvider prefProvider =
(PreferenceProvider)Component.getInstance("preferenceProvider");
+ prefProvider.deleteUserPreferenceValues(getInstance());
+ prefProvider.flush();
+
+ String outcome = super.remove();
+ if (outcome != null) {
+ org.jboss.seam.core.Events.instance().raiseEvent("User.removed",
getInstance());
+ }
+ return outcome;
+ }
+
@Restrict("#{s:hasPermission('User', 'edit',
userHome.instance)}")
public void removePortrait() {
getInstance().getProfile().setImage(null);
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java
(rev 0)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/SpamReportDAO.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -0,0 +1,44 @@
+package org.jboss.seam.wiki.core.dao;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.log.Log;
+import org.jboss.seam.wiki.core.model.WikiComment;
+import org.jboss.seam.wiki.core.model.WikiFeed;
+import org.jboss.seam.wiki.core.model.WikiSpamReport;
+
+@Name("spamReportDAO")
+@AutoCreate
+public class SpamReportDAO
+{
+ @Logger static Log log;
+
+ @In protected EntityManager restrictedEntityManager;
+
+
+ public List<WikiSpamReport> findReports(WikiComment comment) {
+ if (comment == null || comment.getId() == null) throw new
IllegalArgumentException("comment is null or unsaved");
+
+ return restrictedEntityManager
+ .createQuery(
+ "select distinct r from WikiSpamReport r " +
+ " where r.comment = :comment"
+ )
+ .setParameter("comment", comment)
+ .getResultList();
+ }
+
+ public void removeReports(List<WikiSpamReport> reports)
+ {
+ for (WikiSpamReport report : reports)
+ {
+ restrictedEntityManager.remove(report);
+ }
+ }
+}
Added:
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java
===================================================================
---
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java
(rev 0)
+++
branches/community/Seam_2_2/examples/wiki/src/main/org/jboss/seam/wiki/core/model/Blacklist.java 2010-07-27
08:58:14 UTC (rev 13515)
@@ -0,0 +1,58 @@
+package org.jboss.seam.wiki.core.model;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Stores a list of blacklisted e-mail addresses and IP addresses. Any users
+ * matching an entry in this table will not be permitted to register or to create
+ * any type of content.
+ *
+ * @author Shane Bryzak
+ */
+@Entity
+@Table(name = "BLACKLIST")
+public class Blacklist
+{
+ private Long id;
+ private String email;
+ private String ipAddress;
+
+ @Id
+ @GeneratedValue(generator = "wikiSequenceGenerator")
+ @Column(name = "ID")
+ public Long getId()
+ {
+ return id;
+ }
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ @Column(name = "EMAIL")
+ public String getEmail()
+ {
+ return email;
+ }
+
+ public void setEmail(String email)
+ {
+ this.email = email;
+ }
+
+ @Column(name = "IP_ADDRESS")
+ public String getIpAddress()
+ {
+ return ipAddress;
+ }
+
+ public void setIpAddress(String ipAddress)
+ {
+ this.ipAddress = ipAddress;
+ }
+}
Modified: branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-27 08:32:39
UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/view/adminHome_d.xhtml 2010-07-27 08:58:14
UTC (rev 13515)
@@ -290,17 +290,41 @@
</s:div>
<s:div styleClass="commentText plaintext"
rendered="#{not report.comment.useWikiText and report.comment.parent.name ==
report.comment.subject}">
<h:outputText
value="#{wiki:escapeHTML(report.comment.content, true, true)}"
escape="false"/>
- </s:div>
+ </s:div>
+ <div>
+ <h:outputLink
value="#{wikiURLRenderer.renderURL(report.comment)}">
+ <h:outputText
value="#{messages['lacewiki.label.adminHome.spamReport.ViewOriginal']}"/>
+ </h:outputLink>
+ </div>
+
</h:column>
<h:column>
<f:facet name="header">
#{messages['lacewiki.label.adminHome.spamReport.Poster']}
</f:facet>
-
- <h:outputLink
value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
- <h:outputText
value="#{report.comment.createdBy}"/>
- </h:outputLink>
+
+ <s:div
rendered="#{report.comment.ownedByRegularUser}">
+ <s:span styleClass="undecoratedLink">
+ <h:outputLink
value="#{wikiURLRenderer.renderUserProfileURL(report.comment.createdBy)}">
+ <h:outputText
value="#{report.comment.createdBy.fullname}"/>
+ </h:outputLink>
+ </s:span>
+ </s:div>
+
+ <s:div rendered="#{not
report.comment.ownedByRegularUser}">
+ <h:outputText rendered="#{empty
report.comment.fromUserHomepage}"
value="#{report.comment.fromUserName}"/>
+ <s:fragment rendered="#{not empty
report.comment.fromUserHomepage}">
+ <a
href="#{report.comment.fromUserHomepage}">#{report.comment.fromUserName}</a>
+ </s:fragment>
+ <s:fragment rendered="#{not empty
report.comment.fromUserEmail}">
+ <h:outputText
value=" | "/>
+ <h:outputLink
value="#{wiki:escapeEmailURL(wiki:concat('mailto:',
report.comment.fromUserEmail))}">
+ <h:outputText
value="#{wiki:escapeAtSymbol(report.comment.fromUserEmail)}"/>
+ </h:outputLink>
+ </s:fragment>
+ </s:div>
+
</h:column>
</h:dataTable>
Modified: branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml
===================================================================
--- branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml 2010-07-27 08:32:39
UTC (rev 13514)
+++ branches/community/Seam_2_2/examples/wiki/view/userHome_d.xhtml 2010-07-27 08:58:14
UTC (rev 13515)
@@ -332,6 +332,25 @@
</ui:decorate>
</s:fragment>
+ <s:fragment rendered="#{s:hasPermission('User',
'delete', userHome.instance)}">
+ <ui:decorate
template="includes/confirmationAction.xhtml">
+ <ui:param name="label"
value="#{messages['lacewiki.button.userHome.Nuke']}"/>
+ <ui:param name="tabindex" value="1"/>
+ <ui:param name="linkClass" value="button
sessionEventTrigger"/>
+ <ui:param name="escapeLabel"
value="false"/>
+ <ui:param name="jsFunctionName"
value="nukeUser"/>
+ <ui:param name="message"
value="#{messages['lacewiki.label.AreYouSureYouWantToNukePrefix']
+
.concat(userHome.instance.username)
+
.concat(messages['lacewiki.label.AreYouSureYouWantToNukeSuffix'])
+ }"/>
+ <ui:define name="jsFunction">
+ <a:jsFunction name="#{jsFunctionName}"
+ action="#{userHome.nuke}"
+ status="globalStatus"/>
+ </ui:define>
+ </ui:decorate>
+ </s:fragment>
+
</div>
</div>
</div>