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
919146ff
Unverified
Commit
919146ff
authored
Apr 13, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
修复发布文章时勾选同步社区不生效问题
#12757
parent
c454b7be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
43 deletions
+19
-43
src/main/java/org/b3log/solo/event/B3ArticleSender.java
src/main/java/org/b3log/solo/event/B3ArticleSender.java
+2
-2
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+17
-41
No files found.
src/main/java/org/b3log/solo/event/B3ArticleSender.java
View file @
919146ff
...
@@ -48,7 +48,7 @@ import org.json.JSONObject;
...
@@ -48,7 +48,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="https://hacpai.com/member/armstrong">ArmstrongCN</a>
* @author <a href="https://hacpai.com/member/armstrong">ArmstrongCN</a>
* @version 1.0.2.
19, Mar 27
, 2019
* @version 1.0.2.
20, Apr 13
, 2019
* @since 0.3.1
* @since 0.3.1
*/
*/
@Singleton
@Singleton
...
@@ -95,7 +95,7 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
...
@@ -95,7 +95,7 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
return
;
return
;
}
}
if
(
Latkes
.
getServePath
().
contains
(
"localhost"
)
||
Strings
.
isIPv4
(
Latkes
.
getServerHost
()))
{
if
(
StringUtils
.
containsIgnoreCase
(
Latkes
.
getServePath
(),
(
"localhost"
)
)
||
Strings
.
isIPv4
(
Latkes
.
getServerHost
()))
{
LOGGER
.
log
(
Level
.
INFO
,
"Solo is running on local server, ignored push article [title={0}] to Rhy"
,
title
);
LOGGER
.
log
(
Level
.
INFO
,
"Solo is running on local server, ignored push article [title={0}] to Rhy"
,
title
);
return
;
return
;
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
919146ff
...
@@ -51,7 +51,7 @@ import static org.b3log.solo.model.Article.*;
...
@@ -51,7 +51,7 @@ import static org.b3log.solo.model.Article.*;
* Article management service.
* Article management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.
0.0, Feb 10
, 2019
* @version 1.3.
1.0, Apr 13
, 2019
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -299,11 +299,10 @@ public class ArticleMgmtService {
...
@@ -299,11 +299,10 @@ public class ArticleMgmtService {
final
String
articleAbstractText
=
Article
.
getAbstractText
(
article
);
final
String
articleAbstractText
=
Article
.
getAbstractText
(
article
);
article
.
put
(
ARTICLE_ABSTRACT_TEXT
,
articleAbstractText
);
article
.
put
(
ARTICLE_ABSTRACT_TEXT
,
articleAbstractText
);
// Update
final
boolean
postToCommunity
=
article
.
optBoolean
(
Common
.
POST_TO_COMMUNITY
);
final
boolean
postToCommunity
=
article
.
optBoolean
(
Common
.
POST_TO_COMMUNITY
,
true
);
article
.
remove
(
Common
.
POST_TO_COMMUNITY
);
article
.
remove
(
Common
.
POST_TO_COMMUNITY
);
// Do not persist this property
articleRepository
.
update
(
articleId
,
article
);
articleRepository
.
update
(
articleId
,
article
);
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
postToCommunity
);
// Restores the property
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
postToCommunity
);
final
boolean
publishNewArticle
=
Article
.
ARTICLE_STATUS_C_DRAFT
==
oldArticle
.
optInt
(
ARTICLE_STATUS
)
&&
Article
.
ARTICLE_STATUS_C_PUBLISHED
==
article
.
optInt
(
ARTICLE_STATUS
);
final
boolean
publishNewArticle
=
Article
.
ARTICLE_STATUS_C_DRAFT
==
oldArticle
.
optInt
(
ARTICLE_STATUS
)
&&
Article
.
ARTICLE_STATUS_C_PUBLISHED
==
article
.
optInt
(
ARTICLE_STATUS
);
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
...
@@ -362,34 +361,12 @@ public class ArticleMgmtService {
...
@@ -362,34 +361,12 @@ public class ArticleMgmtService {
try
{
try
{
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
Article
.
ARTICLE
);
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
Article
.
ARTICLE
);
final
String
ret
=
addArticleInternal
(
article
);
String
ret
=
article
.
optString
(
Keys
.
OBJECT_ID
);
transaction
.
commit
();
if
(
StringUtils
.
isBlank
(
ret
))
{
ret
=
Ids
.
genTimeMillisId
();
return
ret
;
article
.
put
(
Keys
.
OBJECT_ID
,
ret
);
}
catch
(
final
Exception
e
)
{
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
}
}
throw
new
ServiceException
(
e
.
getMessage
());
}
}
/**
* Adds the specified article for internal invocation purposes.
*
* @param article the specified article
* @return generated article id
* @throws ServiceException service exception
*/
public
String
addArticleInternal
(
final
JSONObject
article
)
throws
ServiceException
{
String
ret
=
article
.
optString
(
Keys
.
OBJECT_ID
);
if
(
StringUtils
.
isBlank
(
ret
))
{
ret
=
Ids
.
genTimeMillisId
();
article
.
put
(
Keys
.
OBJECT_ID
,
ret
);
}
try
{
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
tagsString
=
Tag
.
formatTags
(
tagsString
);
tagsString
=
Tag
.
formatTags
(
tagsString
);
if
(
StringUtils
.
isBlank
(
tagsString
))
{
if
(
StringUtils
.
isBlank
(
tagsString
))
{
...
@@ -425,27 +402,26 @@ public class ArticleMgmtService {
...
@@ -425,27 +402,26 @@ public class ArticleMgmtService {
final
String
articleAbstractText
=
Article
.
getAbstractText
(
article
);
final
String
articleAbstractText
=
Article
.
getAbstractText
(
article
);
article
.
put
(
ARTICLE_ABSTRACT_TEXT
,
articleAbstractText
);
article
.
put
(
ARTICLE_ABSTRACT_TEXT
,
articleAbstractText
);
final
boolean
postToCommunity
=
article
.
optBoolean
(
Common
.
POST_TO_COMMUNITY
,
true
);
final
boolean
postToCommunity
=
article
.
optBoolean
(
Common
.
POST_TO_COMMUNITY
);
article
.
remove
(
Common
.
POST_TO_COMMUNITY
);
// Do not persist this property
article
.
remove
(
Common
.
POST_TO_COMMUNITY
);
articleRepository
.
add
(
article
);
articleRepository
.
add
(
article
);
transaction
.
commit
();
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
postToCommunity
);
// Restores the property
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
postToCommunity
);
if
(
Article
.
ARTICLE_STATUS_C_PUBLISHED
==
article
.
optInt
(
ARTICLE_STATUS
))
{
if
(
Article
.
ARTICLE_STATUS_C_PUBLISHED
==
article
.
optInt
(
ARTICLE_STATUS
))
{
final
JSONObject
eventData
=
new
JSONObject
();
final
JSONObject
eventData
=
new
JSONObject
();
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventData
.
put
(
Article
.
ARTICLE
,
article
);
eventManager
.
fireEventAsynchronously
(
new
Event
<>(
EventTypes
.
ADD_ARTICLE
,
eventData
));
eventManager
.
fireEventAsynchronously
(
new
Event
<>(
EventTypes
.
ADD_ARTICLE
,
eventData
));
}
}
article
.
remove
(
Common
.
POST_TO_COMMUNITY
)
;
return
ret
;
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Adds an article failed"
,
e
);
if
(
transaction
.
isActive
())
{
transaction
.
rollback
();
}
throw
new
ServiceException
(
e
);
throw
new
ServiceException
(
e
.
getMessage
()
);
}
}
return
ret
;
}
}
/**
/**
...
...
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