Skip to content

Commit 8c1800a

Browse files
committed
Expose initProducts with an explicit ProductsConfig for multi-tenant
callers
1 parent 704be5d commit 8c1800a

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

stripe/src/main/java/org/restheart/stripe/StripeInitService.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,23 @@ public void initProducts(String dbName) {
171171
initProducts(dbName, conf.products());
172172
}
173173

174-
private void initProducts(String dbName, ProductsConfig products) {
174+
/**
175+
* Initializes the products mode domain model on {@code dbName} using the given configuration
176+
* instead of the statically configured one.
177+
*
178+
* <p>This is the overload a multi-tenant deployment needs. {@link #initProducts(String)} reads
179+
* collection names from {@code stripeConfig.products}, which on a node serving many tenants is
180+
* either absent or belongs to no tenant in particular — initializing from it would create the
181+
* wrong collections, and leave the ones the tenant actually configured missing. Pass the
182+
* tenant's own {@code ProductsConfig} (RESTHeart Cloud takes it from
183+
* {@code override-stripe-products}) so that what gets created is what that tenant will read
184+
* and write.
185+
*
186+
* @param dbName the database name to initialize
187+
* @param products the configuration to initialize from — collection names, and the inventory
188+
* collection when that tenant uses one
189+
*/
190+
public void initProducts(String dbName, ProductsConfig products) {
175191
var db = mclient.getDatabase(dbName);
176192

177193
LOGGER.info("[stripe] initializing products mode on database '{}'", dbName);

0 commit comments

Comments
 (0)