private static void initialize() throws DataAccessException {
File file = null;
try {
file = Utilities.getClassLoaderFile(SPAM_BLACKLIST_FILE);
} catch (IOException e) {
throw new DataAccessException("I/O exception while initlaizing spam blacklist", e);
}
String regex = "";
String regexText = null;
try {
regexText = FileUtils.readFileToString(file, "UTF-8").trim();
} catch (IOException e) {
throw new DataAccessException("I/O exception while initlaizing spam blacklist", e);
}
String[] tokens = regexText.split("\n");
for (int i = 0; i < tokens.length; i++) {
String token = tokens[i];
if (StringUtils.isBlank(token)) {
continue;
}
if (i > 0) {
regex += "|";
}
regex += token.trim();
}
try {
spamRegexPattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
} catch (PatternSyntaxException e) {
throw new DataAccessException("Failure while parsing spam regular expression list", e);
}
logger.info("Loading spam filter regular expression:" + regex);
}