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
347b3701
Unverified
Commit
347b3701
authored
Apr 15, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
Cleanup code
parent
227b727b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
50 deletions
+37
-50
src/main/java/org/b3log/solo/dev/ArticleGenerator.java
src/main/java/org/b3log/solo/dev/ArticleGenerator.java
+2
-4
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
...b3log/solo/event/comment/ArticleCommentReplyNotifier.java
+2
-5
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
...rg/b3log/solo/event/comment/PageCommentReplyNotifier.java
+1
-2
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
...log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
+16
-19
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
.../solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
+16
-20
No files found.
src/main/java/org/b3log/solo/dev/ArticleGenerator.java
View file @
347b3701
...
@@ -21,7 +21,6 @@ import org.b3log.latke.ioc.inject.Inject;
...
@@ -21,7 +21,6 @@ import org.b3log.latke.ioc.inject.Inject;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Level
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.logging.Logger
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.model.User
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
...
@@ -41,7 +40,7 @@ import java.util.Date;
...
@@ -41,7 +40,7 @@ import java.util.Date;
* Generates some dummy articles for development testing.
* Generates some dummy articles for development testing.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
5, Jul 9, 2017
* @version 1.0.0.
6, Apr 15, 2018
* @since 0.4.0
* @since 0.4.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -67,13 +66,12 @@ public class ArticleGenerator {
...
@@ -67,13 +66,12 @@ public class ArticleGenerator {
/**
/**
* Generates some dummy articles with the specified context.
* Generates some dummy articles with the specified context.
*
*
* @param context the specified context
* @param request the specified request
* @param request the specified request
* @param response the specified response
* @param response the specified response
* @throws IOException io exception
* @throws IOException io exception
*/
*/
@RequestProcessing
(
value
=
"/dev/articles/gen/*"
,
method
=
HTTPRequestMethod
.
GET
)
@RequestProcessing
(
value
=
"/dev/articles/gen/*"
,
method
=
HTTPRequestMethod
.
GET
)
public
void
genArticles
(
final
H
TTPRequestContext
context
,
final
H
ttpServletRequest
request
,
final
HttpServletResponse
response
)
public
void
genArticles
(
final
HttpServletRequest
request
,
final
HttpServletResponse
response
)
throws
IOException
{
throws
IOException
{
if
(
Latkes
.
RuntimeMode
.
DEVELOPMENT
!=
Latkes
.
getRuntimeMode
())
{
if
(
Latkes
.
RuntimeMode
.
DEVELOPMENT
!=
Latkes
.
getRuntimeMode
())
{
LOGGER
.
log
(
Level
.
WARN
,
"Article generation just for development mode, "
+
"current runtime mode is [{0}]"
,
LOGGER
.
log
(
Level
.
WARN
,
"Article generation just for development mode, "
+
"current runtime mode is [{0}]"
,
...
...
src/main/java/org/b3log/solo/event/comment/ArticleCommentReplyNotifier.java
View file @
347b3701
...
@@ -43,7 +43,7 @@ import org.json.JSONObject;
...
@@ -43,7 +43,7 @@ import org.json.JSONObject;
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://www.wanglay.com">Lei Wang</a>
* @author <a href="http://www.wanglay.com">Lei Wang</a>
* @version 1.2.2.
8, Jul 20, 2017
* @version 1.2.2.
9, Apr 15, 2018
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
public
final
class
ArticleCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
...
@@ -64,11 +64,9 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
...
@@ -64,11 +64,9 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
final
JSONObject
comment
=
eventData
.
optJSONObject
(
Comment
.
COMMENT
);
final
JSONObject
comment
=
eventData
.
optJSONObject
(
Comment
.
COMMENT
);
final
JSONObject
article
=
eventData
.
optJSONObject
(
Article
.
ARTICLE
);
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}]"
,
"Processing an event[type={0}, data={1}] in listener[className={2}]"
,
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
());
event
.
getType
(),
eventData
,
ArticleCommentReplyNotifier
.
class
.
getName
());
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
final
String
originalCommentId
=
comment
.
optString
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
);
if
(
Strings
.
isEmptyOrNull
(
originalCommentId
))
{
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
));
...
@@ -87,7 +85,6 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
...
@@ -87,7 +85,6 @@ public final class ArticleCommentReplyNotifier extends AbstractEventListener<JSO
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
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
{
try
{
...
...
src/main/java/org/b3log/solo/event/comment/PageCommentReplyNotifier.java
View file @
347b3701
...
@@ -42,7 +42,7 @@ import org.json.JSONObject;
...
@@ -42,7 +42,7 @@ import org.json.JSONObject;
* This listener is responsible for processing page comment reply.
* This listener is responsible for processing page comment reply.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.
4, Jul 20, 2017
* @version 1.0.2.
5, Apr 15, 2018
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
PageCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
public
final
class
PageCommentReplyNotifier
extends
AbstractEventListener
<
JSONObject
>
{
...
@@ -78,7 +78,6 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
...
@@ -78,7 +78,6 @@ public final class PageCommentReplyNotifier extends AbstractEventListener<JSONOb
final
LatkeBeanManager
beanManager
=
Lifecycle
.
getBeanManager
();
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
{
try
{
...
...
src/main/java/org/b3log/solo/event/ping/AddArticleGoogleBlogSearchPinger.java
View file @
347b3701
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
org
.
b3log
.
solo
.
event
.
ping
;
package
org
.
b3log
.
solo
.
event
.
ping
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.Event
;
import
org.b3log.latke.event.Event
;
...
@@ -36,20 +35,17 @@ import org.json.JSONObject;
...
@@ -36,20 +35,17 @@ import org.json.JSONObject;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
/**
/**
* This listener is responsible for pinging <a href="http://blogsearch.google.com">
* This listener is responsible for pinging <a href="http://blogsearch.google.com">
Google Blog Search Service</a>
*
Google Blog Search Service</a>
asynchronously while adding an article.
* asynchronously while adding an article.
*
*
* <p>
* <li>
* <li>
* <a href="http://www.google.com/help/blogsearch/pinging_API.html">
* <a href="http://www.google.com/help/blogsearch/pinging_API.html">
* About Google Blog Search Pinging Service API</a>
* About Google Blog Search Pinging Service API</a>
* </li>
* </li>
* </p>
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Nov 20, 2015
* @version 1.0.0.
5, Apr 15, 2018
* @see UpdateArticleGoogleBlogSearchPinger
* @see UpdateArticleGoogleBlogSearchPinger
* @since 0.3.1
* @since 0.3.1
*/
*/
...
@@ -92,25 +88,26 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene
...
@@ -92,25 +88,26 @@ public final class AddArticleGoogleBlogSearchPinger extends AbstractEventListene
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
TRACE
,
LOGGER
.
log
(
Level
.
TRACE
,
"Solo runs on local server, so should not ping "
+
"Solo runs on local server, so should not ping "
+
"Google Blog Search Service for the article[title={0}]"
,
"Google Blog Search Service for the article[title={0}]"
,
article
.
getString
(
Article
.
ARTICLE_TITLE
));
article
.
getString
(
Article
.
ARTICLE_TITLE
));
return
;
return
;
}
}
final
String
articlePermalink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
articlePermalink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
spec
=
"http://blogsearch.google.com/ping?name="
+
URLEncoder
.
encode
(
blogTitle
,
"UTF-8"
)
+
"&url="
final
String
spec
=
"http://blogsearch.google.com/ping?name="
+
URLEncoder
.
encode
(
blogTitle
,
"UTF-8"
)
+
+
URLEncoder
.
encode
(
Latkes
.
getServePath
(),
"UTF-8"
)
+
"&changesURL="
+
URLEncoder
.
encode
(
articlePermalink
,
"UTF-8"
);
"&url="
+
URLEncoder
.
encode
(
Latkes
.
getServePath
(),
"UTF-8"
)
+
"&changesURL="
+
URLEncoder
.
encode
(
articlePermalink
,
"UTF-8"
);
LOGGER
.
log
(
Level
.
DEBUG
,
"Request Google Blog Search Service API[{0}] while adding an "
+
"article[title="
+
articleTitle
+
"]"
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Request Google Blog Search Service API[{0}] while adding an "
spec
);
+
"article[title="
+
articleTitle
+
"]"
,
spec
);
final
HTTPRequest
request
=
new
HTTPRequest
();
final
HTTPRequest
request
=
new
HTTPRequest
();
request
.
setURL
(
new
URL
(
spec
));
request
.
setURL
(
new
URL
(
spec
));
URL_FETCH_SERVICE
.
fetchAsync
(
request
);
URL_FETCH_SERVICE
.
fetchAsync
(
request
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Ping Google Blog Search Service fail while adding an article[title="
+
articleTitle
+
"]"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Ping Google Blog Search Service fail while adding an article[title="
+
articleTitle
+
"]"
,
e
);
}
}
}
}
}
}
src/main/java/org/b3log/solo/event/ping/UpdateArticleGoogleBlogSearchPinger.java
View file @
347b3701
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
*/
*/
package
org
.
b3log
.
solo
.
event
.
ping
;
package
org
.
b3log
.
solo
.
event
.
ping
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.Latkes
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.AbstractEventListener
;
import
org.b3log.latke.event.Event
;
import
org.b3log.latke.event.Event
;
...
@@ -36,20 +35,17 @@ import org.json.JSONObject;
...
@@ -36,20 +35,17 @@ import org.json.JSONObject;
import
java.net.URL
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
/**
/**
* This listener is responsible for pinging <a href="http://blogsearch.google.com">
* This listener is responsible for pinging <a href="http://blogsearch.google.com">
Google Blog Search Service</a>
*
Google Blog Search Service</a>
asynchronously while updating an article.
* asynchronously while updating an article.
*
*
* <p>
* <li>
* <li>
* <a href="http://www.google.com/help/blogsearch/pinging_API.html">
* <a href="http://www.google.com/help/blogsearch/pinging_API.html">
* About Google Blog Search Pinging Service API</a>
* About Google Blog Search Pinging Service API</a>
* </li>
* </li>
* </p>
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Nov 20, 2015
* @version 1.0.0.
5, Apr 15, 2018
* @see AddArticleGoogleBlogSearchPinger
* @see AddArticleGoogleBlogSearchPinger
* @since 0.3.1
* @since 0.3.1
*/
*/
...
@@ -86,30 +82,30 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList
...
@@ -86,30 +82,30 @@ public final class UpdateArticleGoogleBlogSearchPinger extends AbstractEventList
try
{
try
{
final
JSONObject
article
=
eventData
.
getJSONObject
(
Article
.
ARTICLE
);
final
JSONObject
article
=
eventData
.
getJSONObject
(
Article
.
ARTICLE
);
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
articleTitle
=
article
.
getString
(
Article
.
ARTICLE_TITLE
);
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
JSONObject
preference
=
preferenceQueryService
.
getPreference
();
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
final
String
blogTitle
=
preference
.
getString
(
Option
.
ID_C_BLOG_TITLE
);
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
))
{
LOGGER
.
log
(
Level
.
TRACE
,
LOGGER
.
log
(
Level
.
TRACE
,
"Solo runs on local server, so should not ping "
+
"Solo runs on local server, so should not ping "
+
"Google Blog Search Service for the article[title={0}]"
,
"Google Blog Search Service for the article[title={0}]"
,
article
.
getString
(
Article
.
ARTICLE_TITLE
));
article
.
getString
(
Article
.
ARTICLE_TITLE
));
return
;
return
;
}
}
final
String
articlePermalink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
articlePermalink
=
Latkes
.
getServePath
()
+
article
.
getString
(
Article
.
ARTICLE_PERMALINK
);
final
String
spec
=
"http://blogsearch.google.com/ping?name="
+
URLEncoder
.
encode
(
blogTitle
,
"UTF-8"
)
+
"&url="
final
String
spec
=
"http://blogsearch.google.com/ping?name="
+
URLEncoder
.
encode
(
blogTitle
,
"UTF-8"
)
+
+
URLEncoder
.
encode
(
Latkes
.
getServePath
(),
"UTF-8"
)
+
"&changesURL="
+
URLEncoder
.
encode
(
articlePermalink
,
"UTF-8"
);
"&url="
+
URLEncoder
.
encode
(
Latkes
.
getServePath
(),
"UTF-8"
)
+
"&changesURL="
+
URLEncoder
.
encode
(
articlePermalink
,
"UTF-8"
);
LOGGER
.
log
(
Level
.
DEBUG
,
LOGGER
.
log
(
Level
.
DEBUG
,
"Request Google Blog Search Service API[{0}] while updateing "
+
"Request Google Blog Search Service API[{0}] while updateing "
+
"an article[title="
+
articleTitle
+
"]"
,
spec
);
"an article[title="
+
articleTitle
+
"]"
,
spec
);
final
HTTPRequest
request
=
new
HTTPRequest
();
final
HTTPRequest
request
=
new
HTTPRequest
();
request
.
setURL
(
new
URL
(
spec
));
request
.
setURL
(
new
URL
(
spec
));
URL_FETCH_SERVICE
.
fetchAsync
(
request
);
URL_FETCH_SERVICE
.
fetchAsync
(
request
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Ping Google Blog Search Service fail while updating an "
+
"article[title="
+
articleTitle
+
"]"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Ping Google Blog Search Service fail while updating an "
+
"article[title="
+
articleTitle
+
"]"
,
e
);
}
}
}
}
}
}
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