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
e3e71952
Unverified
Commit
e3e71952
authored
Sep 07, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔥
删除冗余代码
parent
4d89630a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
55 deletions
+1
-55
src/main/java/org/b3log/solo/processor/RepairProcessor.java
src/main/java/org/b3log/solo/processor/RepairProcessor.java
+1
-55
No files found.
src/main/java/org/b3log/solo/processor/RepairProcessor.java
View file @
e3e71952
...
...
@@ -26,15 +26,12 @@ import org.b3log.latke.mail.MailService;
import
org.b3log.latke.mail.MailService.Message
;
import
org.b3log.latke.mail.MailServiceFactory
;
import
org.b3log.latke.repository.Query
;
import
org.b3log.latke.repository.Repositories
;
import
org.b3log.latke.repository.Transaction
;
import
org.b3log.latke.repository.annotation.Transactional
;
import
org.b3log.latke.servlet.HTTPRequestContext
;
import
org.b3log.latke.servlet.HTTPRequestMethod
;
import
org.b3log.latke.servlet.annotation.RequestProcessing
;
import
org.b3log.latke.servlet.annotation.RequestProcessor
;
import
org.b3log.latke.servlet.renderer.TextHTMLRenderer
;
import
org.b3log.latke.util.CollectionUtils
;
import
org.b3log.solo.model.Article
;
import
org.b3log.solo.model.Option
;
import
org.b3log.solo.model.Tag
;
...
...
@@ -50,7 +47,6 @@ import org.json.JSONArray;
import
org.json.JSONObject
;
import
java.util.List
;
import
java.util.Set
;
/**
* Provides patches on some special issues.
...
...
@@ -59,7 +55,7 @@ import java.util.Set;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.1
5, Aug 2
7, 2018
* @version 1.2.0.1
6, Sep
7, 2018
* @since 0.3.1
*/
@RequestProcessor
...
...
@@ -123,56 +119,6 @@ public class RepairProcessor {
@Inject
private
StatisticMgmtService
statisticMgmtService
;
/**
* Removes unused properties of each article.
*
* @param context the specified context
*/
@RequestProcessing
(
value
=
"/fix/normalization/articles/properties"
,
method
=
HTTPRequestMethod
.
POST
)
public
void
removeUnusedArticleProperties
(
final
HTTPRequestContext
context
)
{
LOGGER
.
log
(
Level
.
INFO
,
"Processes remove unused article properties"
);
final
TextHTMLRenderer
renderer
=
new
TextHTMLRenderer
();
context
.
setRenderer
(
renderer
);
Transaction
transaction
=
null
;
try
{
final
JSONArray
articles
=
articleRepository
.
get
(
new
Query
()).
getJSONArray
(
Keys
.
RESULTS
);
if
(
articles
.
length
()
<=
0
)
{
renderer
.
setContent
(
"No unused article properties"
);
return
;
}
transaction
=
articleRepository
.
beginTransaction
();
final
Set
<
String
>
keyNames
=
Repositories
.
getKeyNames
(
Article
.
ARTICLE
);
for
(
int
i
=
0
;
i
<
articles
.
length
();
i
++)
{
final
JSONObject
article
=
articles
.
getJSONObject
(
i
);
final
JSONArray
names
=
article
.
names
();
final
Set
<
String
>
nameSet
=
CollectionUtils
.
jsonArrayToSet
(
names
);
if
(
nameSet
.
removeAll
(
keyNames
))
{
for
(
final
String
unusedName
:
nameSet
)
{
article
.
remove
(
unusedName
);
}
articleRepository
.
update
(
article
.
getString
(
Keys
.
OBJECT_ID
),
article
);
LOGGER
.
log
(
Level
.
INFO
,
"Found an article[id={0}] exists unused properties[{1}]"
,
article
.
getString
(
Keys
.
OBJECT_ID
),
nameSet
);
}
}
transaction
.
commit
();
}
catch
(
final
Exception
e
)
{
if
(
null
!=
transaction
&&
transaction
.
isActive
())
{
transaction
.
rollback
();
}
LOGGER
.
log
(
Level
.
ERROR
,
e
.
getMessage
(),
e
);
renderer
.
setContent
(
"Removes unused article properties failed, error msg["
+
e
.
getMessage
()
+
"]"
);
}
}
/**
* Restores the signs of preference to default.
*
...
...
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