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
187e37d5
Unverified
Commit
187e37d5
authored
Mar 26, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔊
同步日志
parent
9de00b06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
src/main/java/org/b3log/solo/processor/B3Receiver.java
src/main/java/org/b3log/solo/processor/B3Receiver.java
+24
-8
No files found.
src/main/java/org/b3log/solo/processor/B3Receiver.java
View file @
187e37d5
...
@@ -47,7 +47,7 @@ import java.util.Date;
...
@@ -47,7 +47,7 @@ import java.util.Date;
* Receiving articles and comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* Receiving articles and comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.
0, Feb 18
, 2019
* @version 2.0.1.
1, Mar 26
, 2019
* @since 0.5.5
* @since 0.5.5
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -153,7 +153,9 @@ public class B3Receiver {
...
@@ -153,7 +153,9 @@ public class B3Receiver {
final
JSONObject
articleAuthor
=
userRepository
.
getByUserName
(
articleAuthorName
);
final
JSONObject
articleAuthor
=
userRepository
.
getByUserName
(
articleAuthorName
);
if
(
null
==
articleAuthor
)
{
if
(
null
==
articleAuthor
)
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Not found user ["
+
articleAuthorName
+
"]"
);
final
String
msg
=
"Not found user ["
+
articleAuthorName
+
"]"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
...
@@ -162,18 +164,21 @@ public class B3Receiver {
...
@@ -162,18 +164,21 @@ public class B3Receiver {
final
String
key
=
articleAuthor
.
optString
(
UserExt
.
USER_B3_KEY
);
final
String
key
=
articleAuthor
.
optString
(
UserExt
.
USER_B3_KEY
);
if
(!
StringUtils
.
equals
(
key
,
b3Key
))
{
if
(!
StringUtils
.
equals
(
key
,
b3Key
))
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Wrong key"
);
final
String
msg
=
"Wrong key"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
final
JSONObject
symArticle
=
requestJSONObject
.
optJSONObject
(
Article
.
ARTICLE
);
final
JSONObject
symArticle
=
requestJSONObject
.
optJSONObject
(
Article
.
ARTICLE
);
final
String
title
=
symArticle
.
optString
(
"title"
);
final
String
articleId
=
symArticle
.
optString
(
"id"
);
final
String
articleId
=
symArticle
.
optString
(
"id"
);
final
JSONObject
oldArticle
=
articleQueryService
.
getArticleById
(
articleId
);
final
JSONObject
oldArticle
=
articleQueryService
.
getArticleById
(
articleId
);
if
(
null
==
oldArticle
)
{
if
(
null
==
oldArticle
)
{
final
JSONObject
article
=
new
JSONObject
().
final
JSONObject
article
=
new
JSONObject
().
put
(
Keys
.
OBJECT_ID
,
symArticle
.
optString
(
"id"
)).
put
(
Keys
.
OBJECT_ID
,
symArticle
.
optString
(
"id"
)).
put
(
Article
.
ARTICLE_TITLE
,
symArticle
.
optString
(
"title"
)
).
put
(
Article
.
ARTICLE_TITLE
,
title
).
put
(
Article
.
ARTICLE_CONTENT
,
symArticle
.
optString
(
"content"
)).
put
(
Article
.
ARTICLE_CONTENT
,
symArticle
.
optString
(
"content"
)).
put
(
Article
.
ARTICLE_TAGS_REF
,
symArticle
.
optString
(
"tags"
));
put
(
Article
.
ARTICLE_TAGS_REF
,
symArticle
.
optString
(
"tags"
));
article
.
put
(
Article
.
ARTICLE_AUTHOR_ID
,
articleAuthor
.
getString
(
Keys
.
OBJECT_ID
));
article
.
put
(
Article
.
ARTICLE_AUTHOR_ID
,
articleAuthor
.
getString
(
Keys
.
OBJECT_ID
));
...
@@ -187,6 +192,7 @@ public class B3Receiver {
...
@@ -187,6 +192,7 @@ public class B3Receiver {
article
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
article
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
final
JSONObject
addRequest
=
new
JSONObject
().
put
(
Article
.
ARTICLE
,
article
);
final
JSONObject
addRequest
=
new
JSONObject
().
put
(
Article
.
ARTICLE
,
article
);
articleMgmtService
.
addArticle
(
addRequest
);
articleMgmtService
.
addArticle
(
addRequest
);
LOGGER
.
log
(
Level
.
INFO
,
"Added an article ["
+
title
+
"] via Sym"
);
return
;
return
;
}
}
...
@@ -199,6 +205,7 @@ public class B3Receiver {
...
@@ -199,6 +205,7 @@ public class B3Receiver {
oldArticle
.
put
(
Common
.
POST_TO_COMMUNITY
,
false
);
// Do not send to rhythm
oldArticle
.
put
(
Common
.
POST_TO_COMMUNITY
,
false
);
// Do not send to rhythm
final
JSONObject
updateRequest
=
new
JSONObject
().
put
(
Article
.
ARTICLE
,
oldArticle
);
final
JSONObject
updateRequest
=
new
JSONObject
().
put
(
Article
.
ARTICLE
,
oldArticle
);
articleMgmtService
.
updateArticle
(
updateRequest
);
articleMgmtService
.
updateArticle
(
updateRequest
);
LOGGER
.
log
(
Level
.
INFO
,
"Updated an article ["
+
title
+
"] via Sym"
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
ret
.
put
(
Keys
.
CODE
,
1
).
put
(
Keys
.
MSG
,
e
.
getMessage
());
ret
.
put
(
Keys
.
CODE
,
1
).
put
(
Keys
.
MSG
,
e
.
getMessage
());
...
@@ -257,7 +264,9 @@ public class B3Receiver {
...
@@ -257,7 +264,9 @@ public class B3Receiver {
final
JSONObject
articleAuthor
=
userRepository
.
getByUserName
(
articleAuthorName
);
final
JSONObject
articleAuthor
=
userRepository
.
getByUserName
(
articleAuthorName
);
if
(
null
==
articleAuthor
)
{
if
(
null
==
articleAuthor
)
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Not found user ["
+
articleAuthorName
+
"]"
);
final
String
msg
=
"Not found user ["
+
articleAuthorName
+
"]"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
...
@@ -266,7 +275,9 @@ public class B3Receiver {
...
@@ -266,7 +275,9 @@ public class B3Receiver {
final
String
key
=
articleAuthor
.
optString
(
UserExt
.
USER_B3_KEY
);
final
String
key
=
articleAuthor
.
optString
(
UserExt
.
USER_B3_KEY
);
if
(!
StringUtils
.
equals
(
key
,
b3Key
))
{
if
(!
StringUtils
.
equals
(
key
,
b3Key
))
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Wrong key"
);
final
String
msg
=
"Wrong key"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
...
@@ -275,7 +286,9 @@ public class B3Receiver {
...
@@ -275,7 +286,9 @@ public class B3Receiver {
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
final
JSONObject
article
=
articleRepository
.
get
(
articleId
);
if
(
null
==
article
)
{
if
(
null
==
article
)
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Not found the specified article [id="
+
articleId
+
"]"
);
final
String
msg
=
"Not found the specified article [id="
+
articleId
+
"]"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
...
@@ -298,6 +311,7 @@ public class B3Receiver {
...
@@ -298,6 +311,7 @@ public class B3Receiver {
addUserReq
.
put
(
UserExt
.
USER_B3_KEY
,
""
);
addUserReq
.
put
(
UserExt
.
USER_B3_KEY
,
""
);
try
{
try
{
userMgmtService
.
addUser
(
addUserReq
);
userMgmtService
.
addUser
(
addUserReq
);
LOGGER
.
log
(
Level
.
INFO
,
"Created a user [role="
+
Role
.
VISITOR_ROLE
+
"] via Sym comment"
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Adds a user ["
+
commentName
+
"] failed"
,
e
);
LOGGER
.
log
(
Level
.
ERROR
,
"Adds a user ["
+
commentName
+
"] failed"
,
e
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
...
@@ -309,7 +323,9 @@ public class B3Receiver {
...
@@ -309,7 +323,9 @@ public class B3Receiver {
if
(!
optionQueryService
.
allowComment
()
||
!
article
.
optBoolean
(
Article
.
ARTICLE_COMMENTABLE
))
{
if
(!
optionQueryService
.
allowComment
()
||
!
article
.
optBoolean
(
Article
.
ARTICLE_COMMENTABLE
))
{
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
CODE
,
1
);
ret
.
put
(
Keys
.
MSG
,
"Not allow comment"
);
final
String
msg
=
"Not allow comment"
;
ret
.
put
(
Keys
.
MSG
,
msg
);
LOGGER
.
log
(
Level
.
WARN
,
msg
);
return
;
return
;
}
}
...
...
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