@@ -172,7 +172,7 @@ public NakshaHub(
172172 this .spaceStorageInstance = new NHSpaceStorage (this , new NakshaEventPipelineFactory (this ));
173173 // setup backend storage DB and Hub config
174174 NakshaContext nakshaContext = setupMapAndContext (adminMapId );
175- final NakshaHubConfig finalCfg = this .storageSetup (customCfg , configId , nakshaContext );
175+ final NakshaHubConfig finalCfg = this .storageSetup (customCfg , configId , nakshaContext , adminMapId );
176176 if (finalCfg == null ) {
177177 throw new RuntimeException ("Server configuration not found! Neither in Admin storage nor a default file." );
178178 }
@@ -218,19 +218,19 @@ private NakshaContext setupMapAndContext(String mapId) {
218218 private @ Nullable NakshaHubConfig storageSetup (
219219 final @ Nullable NakshaHubConfig customCfg ,
220220 final @ Nullable String configId ,
221- final @ NotNull NakshaContext nakshaContext
222- ) {
221+ final @ NotNull NakshaContext nakshaContext ,
222+ final @ NotNull String adminMapId ) {
223223 // 1. Create all Admin collections in Admin DB
224- createAdminCollections (nakshaContext );
224+ createAdminCollections (nakshaContext , adminMapId );
225225
226226 // 2. fetch / add latest config
227- return configSetup (nakshaContext , customCfg , configId );
227+ return configSetup (nakshaContext , customCfg , configId , adminMapId );
228228 }
229229
230- private void createAdminCollections (NakshaContext nakshaContext ) {
230+ private void createAdminCollections (NakshaContext nakshaContext , String adminMapId ) {
231231 getAdminStorage ().runInWriteSession (SessionOptions .from (nakshaContext , true ), admin -> {
232232 logger .info ("WriteCollections Request for {}, against Admin storage." , ALL_HUB_INTERNAL_COLLECTIONS );
233- final Response createAdminCollectionsResponse = admin .execute (upsertAdminCollectionsRequest ());
233+ final Response createAdminCollectionsResponse = admin .execute (upsertAdminCollectionsRequest (adminMapId ));
234234 if (createAdminCollectionsResponse instanceof SuccessResponse successResponse ) {
235235 NakshaFeatureList createdCollections = successResponse .getFeatures ();
236236 for (NakshaFeature createdCollection : createdCollections ) {
@@ -253,18 +253,19 @@ private void createAdminCollections(NakshaContext nakshaContext) {
253253 });
254254 }
255255
256- private static WriteRequest upsertAdminCollectionsRequest () {
256+ private static WriteRequest upsertAdminCollectionsRequest (@ NotNull String adminMapId ) {
257257 final WriteRequest writeRequest = new WriteRequest ();
258258 for (String adminCollectionId : ALL_HUB_INTERNAL_COLLECTIONS ) {
259- writeRequest .add (new Write ().upsertCollection (new NakshaCollection (adminCollectionId , NakshaHubAdminStorageIdentifiers . getHubAdminMapId () )));
259+ writeRequest .add (new Write ().upsertCollection (new NakshaCollection (adminCollectionId , adminMapId )));
260260 }
261261 return writeRequest ;
262262 }
263263
264264 private @ Nullable NakshaHubConfig configSetup (
265265 final @ NotNull NakshaContext nakshaContext ,
266266 final @ Nullable NakshaHubConfig customCfg ,
267- final @ Nullable String configId ) {
267+ final @ Nullable String configId ,
268+ final @ NotNull String adminMapId ) {
268269 /*
269270 * Config preference, for a given configId (e.g. "custom-config"):
270271 * 1. Custom config - If provided, persist the same in DB, and use the same for NakshaHub
@@ -276,7 +277,7 @@ private static WriteRequest upsertAdminCollectionsRequest() {
276277 return getAdminStorage ().useWriteSession (SessionOptions .from (nakshaContext , true ), admin -> {
277278 if (customCfg != null ) {
278279 WriteRequest writeCustomCfg = new WriteRequest ()
279- .add (new Write ().upsertFeature (NakshaHubAdminStorageIdentifiers . getHubAdminMapId () , CONFIGS , customCfg ));
280+ .add (new Write ().upsertFeature (adminMapId , CONFIGS , customCfg ));
280281 Response writeCustomCfgResponse = admin .execute (writeCustomCfg );
281282 if (writeCustomCfgResponse instanceof SuccessResponse ) {
282283 admin .commit ();
0 commit comments