Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
52c033db
Commit
52c033db
authored
May 06, 2016
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化 & 文件日志配置
parent
99273811
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
138 additions
and
160 deletions
+138
-160
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+120
-142
src/main/resources/log4j.properties
src/main/resources/log4j.properties
+18
-18
No files found.
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
52c033db
...
...
@@ -41,17 +41,16 @@ import org.json.JSONObject;
* This listener is responsible for processing article comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.1.7, Nov 20, 2015
* @author <a href="http://www.wanglay.com">Lei Wang</a>
* @version 1.2.1.7, May 6, 2016
* @since 0.3.1
*/
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleCommentReplyNotifier
.
class
.
getName
());
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleCommentReplyNotifier
.
class
.
getName
());
/**
* Mail service.
...
...
@@ -64,81 +63,62 @@ public final class ArticleCommentReplyNotifier extends
final
JSONObject
comment
=
eventData
.
optJSONObject
(
Comment
.
COMMENT
);
final
JSONObject
article
=
eventData
.
optJSONObject
(
Article
.
ARTICLE
);
LOGGER
.
log
(
Level
.
DEBUG
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Processing an event[type={0}, data={1}] in listener[className={2}]"
,
new
Object
[]
{
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
()
});
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
new
Object
[]{
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
()});
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
if
(
Strings
.
isEmptyOrNull
(
originalCommentId
))
{
LOGGER
.
log
(
Level
.
DEBUG
,
"This comment[id={0}] is not a reply"
,
comment
.
optString
(
Keys
.
OBJECT_ID
));
LOGGER
.
log
(
Level
.
DEBUG
,
"This comment[id={0}] is not a reply"
,
comment
.
optString
(
Keys
.
OBJECT_ID
));
return
;
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
INFO
,
"Solo runs on local server, so should not send mail"
);
LOGGER
.
log
(
Level
.
INFO
,
"Solo runs on local server, so should not send mail"
);
return
;
}
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
final
PreferenceQueryService
preferenceQueryService
=
beanManager
.
getReference
(
PreferenceQueryService
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepositoryImpl
.
class
);
final
CommentRepository
commentRepository
=
beanManager
.
getReference
(
CommentRepositoryImpl
.
class
);
try
{
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
final
JSONObject
originalComment
=
commentRepository
.
get
(
originalCommentId
);
final
String
originalCommentEmail
=
originalComment
.
getString
(
Comment
.
COMMENT_EMAIL
);
final
String
commentEmail
=
comment
.
getString
(
Comment
.
COMMENT_EMAIL
);
final
JSONObject
originalComment
=
commentRepository
.
get
(
originalCommentId
);
final
String
originalCommentEmail
=
originalComment
.
getString
(
Comment
.
COMMENT_EMAIL
);
if
(
originalCommentEmail
.
equalsIgnoreCase
(
commentEmail
))
{
return
;
}
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
if
(
null
==
preference
)
{
throw
new
EventException
(
"Not found preference"
);
}
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_ADMIN_EMAIL
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
adminEmail
=
preference
.
getString
(
Option
.
ID_C_ADMIN_EMAIL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
final
String
commentContent
=
comment
.
getString
(
Comment
.
COMMENT_CONTENT
);
final
String
commentSharpURL
=
comment
.
getString
(
Comment
.
COMMENT_SHARP_URL
);
final
Message
message
=
new
Message
();
message
.
setFrom
(
adminEmail
);
message
.
addRecipient
(
originalCommentEmail
);
final
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
final
JSONObject
replyNotificationTemplate
=
preferenceQueryService
.
getReplyNotificationTemplate
();
final
String
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
final
String
articleLink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
final
String
articleLink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
commentName
=
comment
.
getString
(
Comment
.
COMMENT_NAME
);
final
String
commentURL
=
comment
.
getString
(
Comment
.
COMMENT_URL
);
String
commenter
;
if
(!
"http://"
.
equals
(
commentURL
))
{
commenter
=
"<a target=\"_blank\" "
+
"href=\""
+
commentURL
+
"\">"
+
commentName
+
"</a>"
;
commenter
=
"<a target=\"_blank\" "
+
"href=\""
+
commentURL
+
"\">"
+
commentName
+
"</a>"
;
}
else
{
commenter
=
commentName
;
}
...
...
@@ -163,10 +143,8 @@ public final class ArticleCommentReplyNotifier extends
.
replace
(
"${replyContent}"
,
commentContent
);
message
.
setHtmlBody
(
mailBody
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
new
Object
[]
{
mailSubject
,
mailBody
,
originalCommentEmail
});
LOGGER
.
log
(
Level
.
DEBUG
,
"Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]"
,
new
Object
[]{
mailSubject
,
mailBody
,
originalCommentEmail
});
mailService
.
send
(
message
);
}
catch
(
final
Exception
e
)
{
...
...
src/main/resources/log4j.properties
View file @
52c033db
...
...
@@ -16,33 +16,33 @@
#
# Description: Solo logging configurations.
# Version: 1.1.0.4, Nov 5, 2015
# Author: Liang Ding
# Version: 1.1.0.4, May 6, 2016
# Author: <a href="http://88250.b3log.org">Liang Ding</a>
# Author: <a href="http://www.wanglay.com">Lei Wang</a>
#
log4j.rootLogger
=
INFO,stdout,
MYFILE
log4j.rootLogger
=
INFO,stdout,
file
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern
=
%d %5p (%c:%L) - %m%n
log4j.appender.stdout.layout.ConversionPattern
=
[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule
=
FATAL
log4j.logger.org.b3log.solo
=
INFO
,MYFILE
log4j.logger.org.b3log.solo
=
INFO
log4j.logger.org.b3log.latke
=
INFO,MYFILE
log4j.logger.org.b3log.latke.util.freemarker.Templates
=
ERROR
,MYFILE
log4j.logger.org.b3log.latke
=
ERROR
log4j.logger.org.b3log.latke.util.freemarker.Templates
=
ERROR
log4j.logger.org.eclipse.jetty
=
WARN
,MYFILE
log4j.logger.freemarker
=
WARN
,MYFILE
log4j.logger.com.mchange
=
WARN
,MYFILE
log4j.logger.org.eclipse.jetty
=
WARN
log4j.logger.freemarker
=
WARN
log4j.logger.com.mchange
=
WARN
log4j.appender.MYFILE
=
org.apache.log4j.DailyRollingFileAppender
#log4j.appender.MYFILE.File=/data/logs/myblog.log
log4j.appender.MYFILE.File
=
/logs/myblog.log
log4j.appender.MYFILE.DatePattern
=
.yyyy-MM-dd
log4j.appender.MYFILE.layout
=
org.apache.log4j.PatternLayout
log4j.appender.MYFILE.layout.ConversionPattern
=
[%d{HH
\:
mm
\:
ss}] %p %c - %m%n
\ No newline at end of file
# File Logger Conf
log4j.appender.file
=
org.apache.log4j.RollingFileAppender
log4j.appender.file.File
=
./solo.log
log4j.appender.file.MaxFileSize
=
10MB
log4j.appender.file.MaxBackupIndex
=
5
log4j.appender.file.layout
=
org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern
=
[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment