add namespaces check in synchronization configuration feature#5192
Conversation
WalkthroughThe recent changes enhance the synchronization validation logic within the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java (1 hunks)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java (1 hunks)
| public ResponseEntity<Void> update(@PathVariable String appId, @PathVariable String namespaceName, | ||
| @RequestBody NamespaceSyncModel model) { | ||
| checkModel(!model.isInvalid()); | ||
| checkModel(!model.isInvalid() && model.syncToNamespacesValid(appId, namespaceName)); |
There was a problem hiding this comment.
LGTM! Add unit tests to verify the new validation logic.
The code changes are approved. Ensure to add unit tests to verify the new validation logic in the update method.
Do you want me to generate the unit testing code or open a GitHub issue to track this task?
a71a904 to
621c151
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java (1 hunks)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/model/NamespaceSyncModel.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
| public boolean syncToNamespacesValid(String appId, String namespaceName) { | ||
| for (NamespaceIdentifier namespaceIdentifier : syncToNamespaces) { | ||
| if (appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals( | ||
| namespaceIdentifier.getNamespaceName())) { | ||
| continue; | ||
| } | ||
| return false; | ||
| } | ||
| return true; |
There was a problem hiding this comment.
Consider using stream and allMatch for better readability.
The current implementation is functional but can be improved for readability and conciseness.
public boolean syncToNamespacesValid(String appId, String namespaceName) {
return syncToNamespaces.stream()
.allMatch(namespaceIdentifier -> appId.equals(namespaceIdentifier.getAppId()) && namespaceName.equals(namespaceIdentifier.getNamespaceName()));
}
What's the purpose of this PR
add namespaces check in synchronization configuration feature
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean testto make sure this pull request doesn't break anything.CHANGESlog.Summary by CodeRabbit
New Features
Bug Fixes