diff options
author | Sophia Tan <sophia_tll@hotmail.com> | 2022-08-17 21:59:59 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-23 19:04:14 +0000 |
commit | cd1b7ce13eb583946482b5eeba3b58c0ad308d16 (patch) | |
tree | 3a713da288d0988f57281bfcb54a3ba9a4c586df /src/mongo/s | |
parent | 35f5a6ea3fdbddccb2f08b1f63fad64066ba605e (diff) | |
download | mongo-cd1b7ce13eb583946482b5eeba3b58c0ad308d16.tar.gz |
SERVER-68421 Remove CommandHelper::parseNsCollectionRequired(StringData dbname, const BSONObj& cmdObj)
Diffstat (limited to 'src/mongo/s')
5 files changed, 14 insertions, 15 deletions
diff --git a/src/mongo/s/commands/cluster_collection_mod_cmd.cpp b/src/mongo/s/commands/cluster_collection_mod_cmd.cpp index 2dd8cd57291..8b73ac91430 100644 --- a/src/mongo/s/commands/cluster_collection_mod_cmd.cpp +++ b/src/mongo/s/commands/cluster_collection_mod_cmd.cpp @@ -74,7 +74,8 @@ public: Status checkAuthForCommand(Client* client, const std::string& dbname, const BSONObj& cmdObj) const override { - const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); + const NamespaceString nss( + CommandHelpers::parseNsCollectionRequired({boost::none, dbname}, cmdObj)); return auth::checkAuthForCollMod( client->getOperationContext(), AuthorizationSession::get(client), nss, cmdObj, true); } diff --git a/src/mongo/s/commands/cluster_create_indexes_cmd.cpp b/src/mongo/s/commands/cluster_create_indexes_cmd.cpp index ef3aacd159c..3a56ea99141 100644 --- a/src/mongo/s/commands/cluster_create_indexes_cmd.cpp +++ b/src/mongo/s/commands/cluster_create_indexes_cmd.cpp @@ -87,10 +87,7 @@ public: const BSONObj& cmdObj, const RequestParser&, BSONObjBuilder& output) final { - // TODO SERVER-67519 Change CommandHelpers::parseNs* methods to construct NamespaceStrings - // with tenantId - const NamespaceString nss( - CommandHelpers::parseNsCollectionRequired(dbName.toStringWithTenantId(), cmdObj)); + const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); LOGV2_DEBUG(22750, 1, "createIndexes: {namespace} cmd: {command}", diff --git a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp index 81afeef46ab..d01690787ee 100644 --- a/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp +++ b/src/mongo/s/commands/cluster_find_and_modify_cmd.cpp @@ -377,7 +377,7 @@ public: const OpMsgRequest& request, ExplainOptions::Verbosity verbosity, rpc::ReplyBuilderInterface* result) const override { - std::string dbName = request.getDatabase().toString(); + const DatabaseName dbName(request.getValidatedTenantId(), request.getDatabase()); const BSONObj& cmdObj = [&]() { // Check whether the query portion needs to be rewritten for FLE. auto findAndModifyRequest = write_ops::FindAndModifyCommandRequest::parse( diff --git a/src/mongo/s/commands/cluster_find_cmd.h b/src/mongo/s/commands/cluster_find_cmd.h index 899cba75722..5c4dca0cd78 100644 --- a/src/mongo/s/commands/cluster_find_cmd.h +++ b/src/mongo/s/commands/cluster_find_cmd.h @@ -68,7 +68,7 @@ public: std::unique_ptr<CommandInvocation> parse(OperationContext* opCtx, const OpMsgRequest& opMsgRequest) override { // TODO: Parse into a QueryRequest here. - return std::make_unique<Invocation>(this, opMsgRequest, opMsgRequest.getDatabase()); + return std::make_unique<Invocation>(this, opMsgRequest); } AllowedOnSecondary secondaryAllowed(ServiceContext* context) const override { @@ -97,10 +97,10 @@ public: class Invocation final : public CommandInvocation { public: - Invocation(const ClusterFindCmdBase* definition, - const OpMsgRequest& request, - StringData dbName) - : CommandInvocation(definition), _request(request), _dbName(dbName) {} + Invocation(const ClusterFindCmdBase* definition, const OpMsgRequest& request) + : CommandInvocation(definition), + _request(request), + _dbName(request.getValidatedTenantId(), request.getDatabase()) {} private: bool supportsWriteConcern() const override { @@ -177,7 +177,7 @@ public: auto aggCmdOnView = uassertStatusOK(query_request_helper::asAggregationCommand(*findCommand)); auto viewAggregationCommand = - OpMsgRequest::fromDBAndBody(_dbName, aggCmdOnView).body; + OpMsgRequest::fromDBAndBody(_dbName.db(), aggCmdOnView).body; auto aggRequestOnView = aggregation_request_helper::parseFromBSON( opCtx, @@ -247,7 +247,7 @@ public: auto aggCmdOnView = uassertStatusOK( query_request_helper::asAggregationCommand(cq->getFindCommandRequest())); auto viewAggregationCommand = - OpMsgRequest::fromDBAndBody(_dbName, aggCmdOnView).body; + OpMsgRequest::fromDBAndBody(_dbName.db(), aggCmdOnView).body; auto aggRequestOnView = aggregation_request_helper::parseFromBSON( opCtx, @@ -303,7 +303,7 @@ public: } const OpMsgRequest& _request; - const StringData _dbName; + const DatabaseName _dbName; }; }; diff --git a/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp b/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp index cd066471f04..eb013343c76 100644 --- a/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp +++ b/src/mongo/s/commands/cluster_set_index_commit_quorum_cmd.cpp @@ -88,7 +88,8 @@ public: Status checkAuthForOperation(OperationContext* opCtx, const std::string& dbName, const BSONObj& cmdObj) const override { - const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbName, cmdObj)); + const NamespaceString nss( + CommandHelpers::parseNsCollectionRequired({boost::none, dbName}, cmdObj)); if (!AuthorizationSession::get(opCtx->getClient()) ->isAuthorizedForActionsOnResource(ResourcePattern::forExactNamespace(nss), ActionType::createIndex)) { |