@@ -344,7 +344,7 @@ public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nulla
344344
345345
346346 return applicationFlux
347- .flatMap (application -> Mono .zip (Mono .just (application ), userMapMono , orgMapMono ))
347+ .flatMap (application -> Mono .zip (Mono .justOrEmpty (application ), userMapMono , orgMapMono ))
348348 .flatMap (tuple2 -> {
349349 // build view
350350 Application application = tuple2 .getT1 ();
@@ -356,24 +356,33 @@ public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nulla
356356 .applicationType (application .getApplicationType ())
357357 .applicationStatus (application .getApplicationStatus ())
358358 .orgId (application .getOrganizationId ())
359- .orgName (orgMap .get (application .getOrganizationId ()).getName ())
359+ .orgName (Optional .ofNullable (orgMap .get (application .getOrganizationId ()))
360+ .map (Organization ::getName )
361+ .orElse ("" ))
360362 .creatorEmail (Optional .ofNullable (userMap .get (application .getCreatedBy ()))
361363 .map (User ::getName )
362364 .orElse ("" ))
363- .createAt (application .getCreatedAt ().toEpochMilli ())
365+ .createAt (Optional .ofNullable (application .getCreatedAt ())
366+ .map (Instant ::toEpochMilli )
367+ .orElse (0L ))
364368 .createBy (application .getCreatedBy ())
365369 .build ();
366370
367371 // marketplace specific fields
368372 return application .getPublishedApplicationDSL (applicationRecordService )
369- .map (pubishedApplicationDSL ->
370- (Map <String , Object >) new HashMap <String , Object >((Map <String , Object >) pubishedApplicationDSL .getOrDefault ("settings" , new HashMap <>())))
371- .switchIfEmpty (Mono .just (new HashMap <>()))
373+ .map (dsl -> {
374+ Object settingsObj = dsl .getOrDefault ("settings" , new HashMap <>());
375+ if (!(settingsObj instanceof Map )) {
376+ return new HashMap <String , Object >(); // fallback if not a map
377+ }
378+ return (Map <String , Object >) settingsObj ;
379+ })
380+ .defaultIfEmpty (new HashMap <>())
372381 .map (settings -> {
373- marketplaceApplicationInfoView .setTitle ((String )settings .getOrDefault ("title" , application .getName ()));
374- marketplaceApplicationInfoView .setCategory ((String )settings .get ("category" ));
375- marketplaceApplicationInfoView .setDescription ((String )settings .get ("description" ));
376- marketplaceApplicationInfoView .setImage ((String )settings .get ("icon" ));
382+ marketplaceApplicationInfoView .setTitle ((String ) settings .getOrDefault ("title" , application .getName ()));
383+ marketplaceApplicationInfoView .setCategory ((String ) settings .get ("category" ));
384+ marketplaceApplicationInfoView .setDescription ((String ) settings .get ("description" ));
385+ marketplaceApplicationInfoView .setImage ((String ) settings .get ("icon" ));
377386 return marketplaceApplicationInfoView ;
378387 });
379388 });
0 commit comments