43
43
44
44
/**
45
45
* This listener is responsible for updating article to B3log Rhythm.
46
- *
47
46
* <p>
48
47
* The B3log Rhythm article update interface: http://rhythm.b3log.org/article (PUT).
49
48
* </p>
50
49
*
51
50
* @author <a href="http://88250.b3log.org">Liang Ding</a>
52
- * @version 1.0.0.2, Nov 20, 2015
51
+ * @version 1.0.0.3, Jun 26, 2017
53
52
* @since 0.6.0
54
53
*/
55
54
public final class ArticleUpdater extends AbstractEventListener <JSONObject > {
56
55
57
56
/**
58
57
* Logger.
59
58
*/
60
- private static final Logger LOGGER = Logger .getLogger (ArticleUpdater .class .getName ());
61
-
62
- /**
63
- * URL fetch service.
64
- */
65
- private final URLFetchService urlFetchService = URLFetchServiceFactory .getURLFetchService ();
59
+ private static final Logger LOGGER = Logger .getLogger (ArticleUpdater .class );
66
60
67
61
/**
68
62
* URL of updating article to Rhythm.
@@ -78,6 +72,11 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
78
72
}
79
73
}
80
74
75
+ /**
76
+ * URL fetch service.
77
+ */
78
+ private final URLFetchService urlFetchService = URLFetchServiceFactory .getURLFetchService ();
79
+
81
80
@ Override
82
81
public void action (final Event <JSONObject > event ) throws EventException {
83
82
final JSONObject data = event .getData ();
@@ -86,7 +85,6 @@ public void action(final Event<JSONObject> event) throws EventException {
86
85
event .getType (), data , ArticleUpdater .class .getName ());
87
86
try {
88
87
final JSONObject originalArticle = data .getJSONObject (Article .ARTICLE );
89
-
90
88
if (!originalArticle .getBoolean (Article .ARTICLE_IS_PUBLISHED )) {
91
89
LOGGER .log (Level .DEBUG , "Ignores post article[title={0}] to Rhythm" , originalArticle .getString (Article .ARTICLE_TITLE ));
92
90
@@ -97,7 +95,6 @@ public void action(final Event<JSONObject> event) throws EventException {
97
95
final PreferenceQueryService preferenceQueryService = beanManager .getReference (PreferenceQueryService .class );
98
96
99
97
final JSONObject preference = preferenceQueryService .getPreference ();
100
-
101
98
if (null == preference ) {
102
99
throw new EventException ("Not found preference" );
103
100
}
@@ -107,7 +104,7 @@ public void action(final Event<JSONObject> event) throws EventException {
107
104
}
108
105
109
106
if (Latkes .getServePath ().contains ("localhost" )) {
110
- LOGGER .log (Level .INFO , "Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm" ,
107
+ LOGGER .log (Level .TRACE , "Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm" ,
111
108
originalArticle .getString (Keys .OBJECT_ID ), originalArticle .getString (Article .ARTICLE_TITLE ));
112
109
return ;
113
110
}
0 commit comments