315157973 commented on a change in pull request #9767:
URL: https://github.com/apache/pulsar/pull/9767#discussion_r585207385
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -2774,36 +2753,41 @@ protected void internalGetRetention(AsyncResponse
asyncResponse, boolean applied
throw new RestException(Status.PRECONDITION_FAILED,
"maxSubscriptionsPerTopic must be 0 or more");
}
- preValidation();
TopicPolicies topicPolicies =
getTopicPolicies(topicName).orElseGet(TopicPolicies::new);
topicPolicies.setMaxSubscriptionsPerTopic(maxSubscriptionsPerTopic);
return
pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName,
topicPolicies);
}
protected Optional<DispatchRate> internalGetReplicatorDispatchRate() {
- preValidation();
return
getTopicPolicies(topicName).map(TopicPolicies::getReplicatorDispatchRate);
}
protected CompletableFuture<Void>
internalSetReplicatorDispatchRate(DispatchRate dispatchRate) {
- preValidation();
TopicPolicies topicPolicies =
getTopicPolicies(topicName).orElseGet(TopicPolicies::new);
topicPolicies.setReplicatorDispatchRate(dispatchRate);
return
pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName,
topicPolicies);
}
- private void preValidation() {
- validateAdminAccessForTenant(namespaceName.getTenant());
- validatePoliciesReadOnlyAccess();
+ protected void validateOwnership() {
if (topicName.isGlobal()) {
validateGlobalNamespaceOwnership(namespaceName);
}
+ validateTopicOwnership(topicName, false);
+ }
+
+ protected void preValidateRead() {
+ validateOwnership();
checkTopicLevelPolicyEnable();
}
+ protected void preValidateWrite() {
+ validatePoliciesReadOnlyAccess();
Review comment:
OK, so the read and write verification can be combined
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]