Skip to content

Commit 3875cd4

Browse files
committed
🎨 clean code
1 parent 5dae13a commit 3875cd4

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/main/java/org/b3log/solo/event/rhythm/ArticleSender.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,21 @@
4343

4444
/**
4545
* This listener is responsible for sending article to B3log Rhythm.
46-
*
4746
* <p>
4847
* The B3log Rhythm article update interface: http://rhythm.b3log.org/article (POST).
4948
* </p>
5049
*
5150
* @author <a href="http://88250.b3log.org">Liang Ding</a>
5251
* @author ArmstrongCN
53-
* @version 1.0.2.8, Nov 20, 2015
52+
* @version 1.0.2.9, Jun 26, 2017
5453
* @since 0.3.1
5554
*/
5655
public final class ArticleSender extends AbstractEventListener<JSONObject> {
5756

5857
/**
5958
* Logger.
6059
*/
61-
private static final Logger LOGGER = Logger.getLogger(ArticleSender.class.getName());
62-
63-
/**
64-
* URL fetch service.
65-
*/
66-
private final URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
60+
private static final Logger LOGGER = Logger.getLogger(ArticleSender.class);
6761

6862
/**
6963
* URL of adding article to Rhythm.
@@ -79,6 +73,11 @@ public final class ArticleSender extends AbstractEventListener<JSONObject> {
7973
}
8074
}
8175

76+
/**
77+
* URL fetch service.
78+
*/
79+
private final URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
80+
8281
@Override
8382
public void action(final Event<JSONObject> event) throws EventException {
8483
final JSONObject data = event.getData();
@@ -87,7 +86,6 @@ public void action(final Event<JSONObject> event) throws EventException {
8786
event.getType(), data, ArticleSender.class.getName());
8887
try {
8988
final JSONObject originalArticle = data.getJSONObject(Article.ARTICLE);
90-
9189
if (!originalArticle.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
9290
LOGGER.log(Level.DEBUG, "Ignores post article[title={0}] to Rhythm", originalArticle.getString(Article.ARTICLE_TITLE));
9391

@@ -98,7 +96,6 @@ public void action(final Event<JSONObject> event) throws EventException {
9896
final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
9997

10098
final JSONObject preference = preferenceQueryService.getPreference();
101-
10299
if (null == preference) {
103100
throw new EventException("Not found preference");
104101
}
@@ -108,7 +105,7 @@ public void action(final Event<JSONObject> event) throws EventException {
108105
}
109106

110107
if (Latkes.getServePath().contains("localhost")) {
111-
LOGGER.log(Level.INFO, "Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
108+
LOGGER.log(Level.TRACE, "Solo runs on local server, so should not send this article[id={0}, title={1}] to Rhythm",
112109
originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE));
113110
return;
114111
}

src/main/java/org/b3log/solo/event/rhythm/ArticleUpdater.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,20 @@
4343

4444
/**
4545
* This listener is responsible for updating article to B3log Rhythm.
46-
*
4746
* <p>
4847
* The B3log Rhythm article update interface: http://rhythm.b3log.org/article (PUT).
4948
* </p>
5049
*
5150
* @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
5352
* @since 0.6.0
5453
*/
5554
public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
5655

5756
/**
5857
* Logger.
5958
*/
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);
6660

6761
/**
6862
* URL of updating article to Rhythm.
@@ -78,6 +72,11 @@ public final class ArticleUpdater extends AbstractEventListener<JSONObject> {
7872
}
7973
}
8074

75+
/**
76+
* URL fetch service.
77+
*/
78+
private final URLFetchService urlFetchService = URLFetchServiceFactory.getURLFetchService();
79+
8180
@Override
8281
public void action(final Event<JSONObject> event) throws EventException {
8382
final JSONObject data = event.getData();
@@ -86,7 +85,6 @@ public void action(final Event<JSONObject> event) throws EventException {
8685
event.getType(), data, ArticleUpdater.class.getName());
8786
try {
8887
final JSONObject originalArticle = data.getJSONObject(Article.ARTICLE);
89-
9088
if (!originalArticle.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
9189
LOGGER.log(Level.DEBUG, "Ignores post article[title={0}] to Rhythm", originalArticle.getString(Article.ARTICLE_TITLE));
9290

@@ -97,7 +95,6 @@ public void action(final Event<JSONObject> event) throws EventException {
9795
final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
9896

9997
final JSONObject preference = preferenceQueryService.getPreference();
100-
10198
if (null == preference) {
10299
throw new EventException("Not found preference");
103100
}
@@ -107,7 +104,7 @@ public void action(final Event<JSONObject> event) throws EventException {
107104
}
108105

109106
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",
111108
originalArticle.getString(Keys.OBJECT_ID), originalArticle.getString(Article.ARTICLE_TITLE));
112109
return;
113110
}

0 commit comments

Comments
 (0)