Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
openSource
apollo
Commits
39dc2979
Unverified
Commit
39dc2979
authored
Jan 24, 2018
by
张乐
Committed by
GitHub
Jan 24, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #934 from nobodyiam/fix-ConfigChangeContentBuilder-item
Fix ConfigChangeContentBuilder update item issue
parents
13eda7c9
3fc83f1e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
ConfigChangeContentBuilder.java
...ramework/apollo/biz/utils/ConfigChangeContentBuilder.java
+17
-6
No files found.
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/utils/ConfigChangeContentBuilder.java
View file @
39dc2979
...
...
@@ -9,6 +9,7 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
import
java.util.Date
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.springframework.beans.BeanUtils
;
public
class
ConfigChangeContentBuilder
{
...
...
@@ -22,14 +23,14 @@ public class ConfigChangeContentBuilder {
public
ConfigChangeContentBuilder
createItem
(
Item
item
)
{
if
(!
StringUtils
.
isEmpty
(
item
.
getKey
())){
createItems
.
add
(
item
);
createItems
.
add
(
cloneItem
(
item
)
);
}
return
this
;
}
public
ConfigChangeContentBuilder
updateItem
(
Item
oldItem
,
Item
newItem
)
{
if
(!
oldItem
.
getValue
().
equals
(
newItem
.
getValue
())){
ItemPair
itemPair
=
new
ItemPair
(
oldItem
,
newItem
);
ItemPair
itemPair
=
new
ItemPair
(
cloneItem
(
oldItem
),
cloneItem
(
newItem
)
);
updateItems
.
add
(
itemPair
);
}
return
this
;
...
...
@@ -37,7 +38,7 @@ public class ConfigChangeContentBuilder {
public
ConfigChangeContentBuilder
deleteItem
(
Item
item
)
{
if
(!
StringUtils
.
isEmpty
(
item
.
getKey
()))
{
deleteItems
.
add
(
item
);
deleteItems
.
add
(
cloneItem
(
item
)
);
}
return
this
;
}
...
...
@@ -48,16 +49,18 @@ public class ConfigChangeContentBuilder {
public
String
build
()
{
//因为事务第一段提交并没有更新时间,所以build时统一更新
Date
now
=
new
Date
();
for
(
Item
item
:
createItems
)
{
item
.
setDataChangeLastModifiedTime
(
n
ew
Date
()
);
item
.
setDataChangeLastModifiedTime
(
n
ow
);
}
for
(
ItemPair
item
:
updateItems
)
{
item
.
newItem
.
setDataChangeLastModifiedTime
(
n
ew
Date
()
);
item
.
newItem
.
setDataChangeLastModifiedTime
(
n
ow
);
}
for
(
Item
item
:
deleteItems
)
{
item
.
setDataChangeLastModifiedTime
(
n
ew
Date
()
);
item
.
setDataChangeLastModifiedTime
(
n
ow
);
}
return
gson
.
toJson
(
this
);
}
...
...
@@ -73,4 +76,12 @@ public class ConfigChangeContentBuilder {
}
}
Item
cloneItem
(
Item
source
)
{
Item
target
=
new
Item
();
BeanUtils
.
copyProperties
(
source
,
target
);
return
target
;
}
}
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