Skip to content

Commit a71a904

Browse files
committed
add namespaces check in synchronization configuration feature
1 parent 49bd8cc commit a71a904

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public List<ItemDiffs> diff(@RequestBody NamespaceSyncModel model) {
195195
@PutMapping(value = "/apps/{appId}/namespaces/{namespaceName}/items", consumes = {"application/json"})
196196
public ResponseEntity<Void> update(@PathVariable String appId, @PathVariable String namespaceName,
197197
@RequestBody NamespaceSyncModel model) {
198-
checkModel(!model.isInvalid());
198+
checkModel(!model.isInvalid() && model.syncToNamespacesValid(appId, namespaceName));
199199
boolean hasPermission = permissionValidator.hasModifyNamespacePermission(appId, namespaceName);
200200
Env envNoPermission = null;
201201
// if uses has ModifyNamespace permission then he has permission

apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java

+11
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,17 @@ public boolean isInvalid() {
4141
return false;
4242
}
4343

44+
public boolean syncToNamespacesValid(String appId, String namespaceName) {
45+
for (NamespaceIdentifier namespaceIdentifier : syncToNamespaces) {
46+
if (appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals(
47+
namespaceIdentifier.getNamespaceName())) {
48+
continue;
49+
}
50+
return false;
51+
}
52+
return true;
53+
}
54+
4455
public List<NamespaceIdentifier> getSyncToNamespaces() {
4556
return syncToNamespaces;
4657
}

0 commit comments

Comments
 (0)