Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad164cb

Browse files
committed
fix#1968: add null checks when retrieving marketplace info
1 parent86674b6 commitad164cb

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

‎server/api-service/lowcoder-server/src/main/java/org/lowcoder/api/home/UserHomeApiServiceImpl.java‎

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public Flux<MarketplaceApplicationInfoView> getAllMarketplaceApplications(@Nulla
344344

345345

346346
returnapplicationFlux
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
Applicationapplication =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
returnapplication.getPublishedApplicationDSL(applicationRecordService)
369-
.map(pubishedApplicationDSL ->
370-
(Map<String,Object>)newHashMap<String,Object>((Map<String,Object>)pubishedApplicationDSL.getOrDefault("settings",newHashMap<>())))
371-
.switchIfEmpty(Mono.just(newHashMap<>()))
373+
.map(dsl -> {
374+
ObjectsettingsObj =dsl.getOrDefault("settings",newHashMap<>());
375+
if (!(settingsObjinstanceofMap)) {
376+
returnnewHashMap<String,Object>();// fallback if not a map
377+
}
378+
return (Map<String,Object>)settingsObj;
379+
})
380+
.defaultIfEmpty(newHashMap<>())
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
returnmarketplaceApplicationInfoView;
378387
});
379388
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp