Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic type check for Item value #4542

Merged
merged 42 commits into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d05a3ef
增加配置项类型判断,后端以及sql修改。
furaul Aug 31, 2022
2493e02
apollo配置项增加类型校验
Bobji Aug 31, 2022
eda2cbd
update CHANGES.md
Bobji Aug 31, 2022
ada1e94
Merge branch 'master' into master
furaul Aug 31, 2022
2fa847f
Merge remote-tracking branch 'origin/master'
Bobji Aug 31, 2022
c34ac0d
Update apollo-portal/src/main/resources/static/i18n/zh-CN.json
furaul Aug 31, 2022
50d24d8
add ddl sql to delta file
Bobji Sep 2, 2022
35731fd
Merge remote-tracking branch 'origin/master'
Bobji Sep 2, 2022
d185ab2
Merge branch 'master' into master
furaul Sep 2, 2022
07da8c8
add ddl sql to delta file ( in a new foler v200-v210)
Bobji Sep 4, 2022
8037240
Merge branch 'master' of https://github.com/furaul/apollo
Bobji Sep 4, 2022
5392e04
Merge branch 'master' into master
nobodyiam Sep 5, 2022
81ece95
Update scripts/sql/delta/v200-v210/apolloconfigdb-v200-v210.sql
furaul Sep 6, 2022
4c02770
Update scripts/sql/apolloconfigdb.sql
furaul Sep 6, 2022
5f9a0d6
Merge branch 'master' into master
furaul Sep 10, 2022
0a1f823
Merge branch 'master' into master
nobodyiam Sep 11, 2022
26270b9
[openapi] add item type
furaul Sep 12, 2022
6b983a0
Optimize the code after review.
Bobji Sep 12, 2022
3687796
[openapi] add type check.
furaul Sep 12, 2022
95a8bb4
Fix unit tests.
furaul Sep 12, 2022
013ad40
Merge branch 'master' of https://github.com/furaul/apollo
furaul Sep 12, 2022
8d3d9f1
Merge branch 'master' into master
furaul Sep 12, 2022
94b2a83
Merge branch 'master' into master
nobodyiam Sep 12, 2022
ebff5a3
Update apollo-portal/src/main/resources/static/scripts/directive/item…
furaul Sep 12, 2022
84915d4
Update apollo-portal/src/main/resources/static/scripts/directive/item…
furaul Sep 12, 2022
287c0a0
Update apollo-portal/src/main/resources/static/scripts/directive/item…
furaul Sep 12, 2022
bfbf475
Update apollo-portal/src/main/resources/static/scripts/directive/item…
furaul Sep 12, 2022
595c689
Update apollo-portal/src/main/resources/static/scripts/directive/item…
furaul Sep 12, 2022
6bb23c2
Fix adminservice unit tests.
furaul Sep 12, 2022
9d7fc02
Revert "Optimize the code after review."
furaul Sep 12, 2022
2e28067
Re optimize the code after review.
furaul Sep 12, 2022
d1353d6
1. use english comments.
furaul Sep 12, 2022
74fe467
move openapi check to service side.
furaul Sep 12, 2022
45d52fb
move openapi check to service side.
furaul Sep 12, 2022
8f83d27
move type check to com.ctrip.framework.apollo.biz.service.ItemService.
furaul Sep 12, 2022
42e4856
add type in gray and related namespace pages.
furaul Sep 12, 2022
e2a0928
correct comments and update com.ctrip.framework.apollo.biz.service.It…
furaul Sep 12, 2022
92c559a
Fix 'Type missing problem' while click 'Full Release' in Grayscale Ve…
furaul Sep 17, 2022
7f3967b
correct comments
furaul Sep 17, 2022
5ece455
Merge branch 'master' into master
nobodyiam Sep 18, 2022
7f774e4
Add unit tests for ItemService.
furaul Sep 18, 2022
e129c00
Merge branch 'master' of https://github.com/furaul/apollo
furaul Sep 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Apollo 2.1.0
* [add configuration processor for portal developers](https://github.com/apolloconfig/apollo/pull/4521)
* [Add a potential json value check feature](https://github.com/apolloconfig/apollo/pull/4519)
* [Add index for table ReleaseHistory](https://github.com/apolloconfig/apollo/pull/4550)
* [Add basic type check for Item value](https://github.com/apolloconfig/apollo/pull/4542)
* [add an option to custom oidc userDisplayName](https://github.com/apolloconfig/apollo/pull/4507)
* [fix openapi item with url illegalKey 400 error](https://github.com/apolloconfig/apollo/pull/4549)
* [fix the exception occurred when publish/rollback namespaces with grayrelease](https://github.com/apolloconfig/apollo/pull/4564)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ public ItemDTO update(@PathVariable("appId") String appId,

Item beforeUpdateItem = BeanUtils.transform(Item.class, managedEntity);

//protect. only value,comment,lastModifiedBy can be modified
//protect. only value,type,comment,lastModifiedBy can be modified
managedEntity.setType(entity.getType());
furaul marked this conversation as resolved.
Show resolved Hide resolved
managedEntity.setValue(entity.getValue());
managedEntity.setComment(entity.getComment());
managedEntity.setDataChangeLastModifiedBy(entity.getDataChangeLastModifiedBy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public class Item extends BaseEntity {
@Column(name = "key", nullable = false)
private String key;

@Column(name = "type")
private int type;

@Column(name = "value")
@Lob
private String value;
Expand Down Expand Up @@ -88,8 +91,17 @@ public void setLineNum(Integer lineNum) {
this.lineNum = lineNum;
}

public int getType() {
return type;
}

public void setType(int type) {
this.type = type;
}

public String toString() {
return toStringHelper().add("namespaceId", namespaceId).add("key", key).add("value", value)
.add("lineNum", lineNum).add("comment", comment).toString();
return toStringHelper().add("namespaceId", namespaceId).add("key", key)
.add("type", type).add("value", value)
.add("lineNum", lineNum).add("comment", comment).toString();
}
}
44 changes: 22 additions & 22 deletions apollo-biz/src/test/resources/sql/release-creation-test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ INSERT INTO `app` ( `AppId`, `Name`, `OrgId`, `OrgName`, `OwnerName`, `OwnerEmai
/* normal namespace*/
INSERT INTO `cluster` ( `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`) VALUES ( 'only-master', 'test', 0, 0, 'default', 'default');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'test', 'only-master', 'application', 0, 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k2', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k3', 'v3', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k2', '0', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(100, 'k3', '0', 'v3', '', 'apollo', 'apollo');


/* namespace has branch. master has items but branch has not item*/
Expand All @@ -30,9 +30,9 @@ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `Dat
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'test', 'default1', 'application', 0, 'apollo', 'apollo');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(102, 'test', 'child-cluster1', 'application', 0, 'apollo', 'apollo');

INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k2', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k3', 'v3', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k2', '0', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(101, 'k3', '0', 'v3', '', 'apollo', 'apollo');

INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default1', 'application', 'child-cluster1', '[]', 1155, 1);

Expand All @@ -45,10 +45,10 @@ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `Dat
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'test', 'default2', 'application', 0, 'apollo', 'apollo');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'test', 'child-cluster2', 'application', 0, 'apollo', 'apollo');

INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k2', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k3', 'v3', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'k1', 'v1-1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k2', '0', 'v2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(103, 'k3', '0', 'v3', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(104, 'k1', '0', 'v1-1', '', 'apollo', 'apollo');

INSERT INTO `grayreleaserule` (`AppId`, `ClusterName`, `NamespaceName`, `BranchName`, `Rules`, `ReleaseId`, `BranchStatus`)VALUES ('test', 'default2', 'application', 'child-cluster2', '[]', 1155, 1);

Expand All @@ -59,9 +59,9 @@ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `Dat
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'test', 'default3', 'application', 0, 'apollo', 'apollo');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'test', 'child-cluster3', 'application', 0, 'apollo', 'apollo');

INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k2', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'k1', 'v1-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(105, 'k2', '0', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(106, 'k1', '0', 'v1-2', '', 'apollo', 'apollo');

INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(1, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default3', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0);
INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(2, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster3', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3"}', 0);
Expand All @@ -75,10 +75,10 @@ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `Dat
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'test', 'default4', 'application', 0, 'apollo', 'apollo');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'test', 'child-cluster4', 'application', 0, 'apollo', 'apollo');

INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k2', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k1', 'v1-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k4', 'v4', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(107, 'k2', '0', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k1', '0', 'v1-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(108, 'k4', '0', 'v4', '', 'apollo', 'apollo');

INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(3, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default4', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0);

Expand All @@ -91,11 +91,11 @@ INSERT INTO `cluster` (ID, `Name`, `AppId`, `ParentClusterId`, `IsDeleted`, `Dat
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'test', 'default5', 'application', 0, 'apollo', 'apollo');
INSERT INTO `namespace` (ID, `AppId`, `ClusterName`, `NamespaceName`, `IsDeleted`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'test', 'child-cluster5', 'application', 0, 'apollo', 'apollo');

INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k1', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k2', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k1', 'v1-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k4', 'v4', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k6', 'v6', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k1', '0', 'v1', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(109, 'k2', '0', 'v2-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k1', '0', 'v1-2', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k4', '0', 'v4', '', 'apollo', 'apollo');
INSERT INTO `item` (`NamespaceId`, `Key`, `Type`, `Value`, `Comment`, `DataChange_CreatedBy`, `DataChange_LastModifiedBy`)VALUES(1010, 'k6', '0', 'v6', '', 'apollo', 'apollo');

INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(4, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'default5', 'application', '{"k1":"v1","k2":"v2","k3":"v3"}', 0);
INSERT INTO `release` (`Id`, `ReleaseKey`, `Name`, `Comment`, `AppId`, `ClusterName`, `NamespaceName`, `Configurations`, `IsAbandoned`)VALUES(5, '20160823102253-fc0071ddf9fd3260', '20160823101703-release', '', 'test', 'child-cluster5', 'application', '{"k1":"v1-1","k2":"v2","k3":"v3","k4":"v4","k5":"v5"}', 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class ItemDTO extends BaseDTO{

private String key;

private int type;

private String value;

private String comment;
Expand Down Expand Up @@ -90,4 +92,12 @@ public void setLineNum(int lineNum) {
this.lineNum = lineNum;
}

public int getType() {
return type;
}

public void setType(int type) {
this.type = type;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,7 @@ protected void checkSize(int size) {
Preconditions.checkArgument(size > 0, "size should be positive number");
}

protected void checkItemType(int type) {
furaul marked this conversation as resolved.
Show resolved Hide resolved
Preconditions.checkArgument(type >= 0 && type <= 3, "type should be in [0, 3]");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public OpenItemDTO createItem(String appId, String env, String clusterName, Stri
checkNotEmpty(env, "Env");
checkNotEmpty(itemDTO.getKey(), "Item key");
checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by");
checkItemType(itemDTO.getType());

OpenApiPathBuilder pathBuilder = OpenApiPathBuilder.newBuilder()
.envsPathVal(env)
Expand Down Expand Up @@ -116,6 +117,7 @@ public void updateItem(String appId, String env, String clusterName, String name
checkNotEmpty(env, "Env");
checkNotEmpty(itemDTO.getKey(), "Item key");
checkNotEmpty(itemDTO.getDataChangeLastModifiedBy(), "Item modified by");
checkItemType(itemDTO.getType());

OpenApiPathBuilder pathBuilder = OpenApiPathBuilder.newBuilder()
.envsPathVal(env)
Expand Down Expand Up @@ -145,6 +147,7 @@ public void createOrUpdateItem(String appId, String env, String clusterName, Str
checkNotEmpty(env, "Env");
checkNotEmpty(itemDTO.getKey(), "Item key");
checkNotEmpty(itemDTO.getDataChangeCreatedBy(), "Item created by");
checkItemType(itemDTO.getType());

if (Strings.isNullOrEmpty(itemDTO.getDataChangeLastModifiedBy())) {
itemDTO.setDataChangeLastModifiedBy(itemDTO.getDataChangeCreatedBy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class OpenItemDTO extends BaseDTO {

private String key;

private int type;

private String value;

private String comment;
Expand All @@ -32,6 +34,14 @@ public void setKey(String key) {
this.key = key;
}

public int getType() {
return type;
}

public void setType(int type) {
this.type = type;
}

public String getValue() {
return value;
}
Expand All @@ -51,13 +61,15 @@ public void setComment(String comment) {
@Override
public String toString() {
return "OpenItemDTO{" +
"key='" + key + '\'' +
", value='" + value + '\'' +
", comment='" + comment + '\'' +
", dataChangeCreatedBy='" + dataChangeCreatedBy + '\'' +
", dataChangeLastModifiedBy='" + dataChangeLastModifiedBy + '\'' +
", dataChangeCreatedTime=" + dataChangeCreatedTime +
", dataChangeLastModifiedTime=" + dataChangeLastModifiedTime +
'}';
"key='" + key + '\'' +
", type='" + type + '\'' +
", value='" + value + '\'' +
", comment='" + comment + '\'' +
", dataChangeCreatedBy='" + dataChangeCreatedBy + '\'' +
", dataChangeLastModifiedBy='" + dataChangeLastModifiedBy + '\'' +
", dataChangeCreatedTime=" + dataChangeCreatedTime +
", dataChangeLastModifiedTime=" + dataChangeLastModifiedTime +
'}';
}

}
Loading