import mir.entity.Entity;
import mir.entity.adapter.EntityAdapterModel;
import mir.log.LoggerWrapper;
+import mir.module.EntityNotFoundExc;
import mir.session.Request;
import mir.util.DateTimeRoutines;
import mir.util.EntityUtility;
import mir.util.GeneratorFormatAdapters;
-import mir.util.StringRoutines;
import mircoders.abuse.FilterEngine;
import mircoders.entity.EntityComment;
import mircoders.entity.EntityContent;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
private boolean cookieOnBlock;
private String articleBlockAction;
private String commentBlockAction;
- private List log;
+ private final List log = new ArrayList();
private File configFile = MirGlobal.config().getFile("Abuse.Config");
private FilterEngine filterEngine;
filterEngine = new FilterEngine(aModel);
model = aModel;
- log = new ArrayList();
-
try {
configuration = MirPropertiesConfiguration.instance();
}
ModuleComment commentModule = new ModuleComment();
synchronized (log) {
- try {
- List result = new ArrayList();
+ List result = new ArrayList();
- Iterator i = log.iterator();
- while (i.hasNext()) {
- LogEntry logEntry = (LogEntry) i.next();
- Map entry = new HashMap();
+ Iterator i = log.iterator();
+ while (i.hasNext()) {
+ LogEntry logEntry = (LogEntry) i.next();
+ Map entry = new HashMap();
- entry.put("ip", logEntry.getIpNumber());
- entry.put("id", logEntry.getId());
- entry.put("timestamp", new GeneratorFormatAdapters.DateFormatAdapter(logEntry.getTimeStamp(), MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));
+ entry.put("ip", logEntry.getIpNumber());
+ entry.put("id", logEntry.getId());
+ entry.put("timestamp", new GeneratorFormatAdapters.DateFormatAdapter(logEntry.getTimeStamp(), MirPropertiesConfiguration.instance().getString("Mir.DefaultTimezone")));
- if (logEntry.getIsArticle()) {
- entry.put("type", "content");
+ if (logEntry.getIsArticle()) {
+ entry.put("type", "content");
+ try {
entry.put("object",
model.makeEntityAdapter("content", contentModule.getById(logEntry.getId())));
}
- else {
- entry.put("type", "comment");
+ catch (EntityNotFoundExc e) {
+ entry.put("object", null);
+ }
+ }
+ else {
+ entry.put("type", "comment");
+ try {
entry.put("object",
model.makeEntityAdapter("comment", commentModule.getById(logEntry.getId())));
}
-
- entry.put("browser", logEntry.getBrowserString());
- entry.put("filtertag", logEntry.getMatchingFilterTag());
-
- result.add(entry);
+ catch (EntityNotFoundExc e) {
+ entry.put("object", null);
+ }
}
- return result;
- }
- catch (Throwable t) {
- throw new RuntimeException(t.toString());
+ entry.put("browser", logEntry.getBrowserString());
+ entry.put("filtertag", logEntry.getMatchingFilterTag());
+
+ result.add(entry);
}
+
+ return result;
}
}
public synchronized void load() {
try {
- ExtendedProperties configuration = new ExtendedProperties();
-
- try {
- configuration = new ExtendedProperties(configFile.getAbsolutePath());
- }
- catch (FileNotFoundException e) {
- }
+ ExtendedProperties configuration = new ExtendedProperties(configFile.getAbsolutePath());
setOpenPostingDisabled(configuration.getString("abuse.openPostingDisabled", "0").equals("1"));
setOpenPostingPassword(configuration.getString("abuse.openPostingPassword", "0").equals("1"));
Iterator i = MirGlobal.localizer().adminInterface().simpleArticleOperations().iterator();
while (i.hasNext()) {
- MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =
- (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();
+ MirAdminInterfaceLocalizer.EntityOperation operation =
+ (MirAdminInterfaceLocalizer.EntityOperation) i.next();
Map action = new HashMap();
action.put("resource", operation.getName());
Iterator i = MirGlobal.localizer().adminInterface().simpleCommentOperations().iterator();
while (i.hasNext()) {
- MirAdminInterfaceLocalizer.MirSimpleEntityOperation operation =
- (MirAdminInterfaceLocalizer.MirSimpleEntityOperation) i.next();
+ MirAdminInterfaceLocalizer.EntityOperation operation =
+ (MirAdminInterfaceLocalizer.EntityOperation) i.next();
Map action = new HashMap();
action.put("resource", operation.getName());
}
}
- private String escapeConfigListEntry(String aFilterPart) {
- return StringRoutines.replaceStringCharacters(aFilterPart,
- new char[] {'\\', ':'},
- new String[] {"\\\\", "\\:"});
- }
-
- private String escapeFilterPart(String aFilterPart) {
- return StringRoutines.replaceStringCharacters(aFilterPart,
- new char[] {'\\', '\n', '\r', '\t', ' '},
- new String[] {"\\\\", "\\n", "\\r", "\\t", "\\ "});
- }
-
- private String deescapeFilterPart(String aFilterPart) {
- return StringRoutines.replaceEscapedStringCharacters(aFilterPart,
- '\\',
- new char[] {'\\', ':', 'n', 'r', 't', ' '},
- new String[] {"\\", ":", "\n", "\r", "\t", " "});
- }
-
private static class LogEntry {
private String ipNumber;
private String browserString;