UpdateLayout Null Pointer Exception : In case the layouts are null or the DSL is null, it should be handled gracefully.
This commit is contained in:
parent
c8ee68b7aa
commit
de722fff4e
|
|
@ -71,8 +71,13 @@ public class LayoutActionServiceImpl implements LayoutActionService {
|
||||||
public Mono<Layout> updateLayout(String pageId, String layoutId, Layout layout) {
|
public Mono<Layout> updateLayout(String pageId, String layoutId, Layout layout) {
|
||||||
String dslString = "";
|
String dslString = "";
|
||||||
|
|
||||||
// Convert the DSL into a String
|
|
||||||
JSONObject dsl = layout.getDsl();
|
JSONObject dsl = layout.getDsl();
|
||||||
|
if (dsl == null) {
|
||||||
|
// There is no DSL here. No need to process anything. Return as is.
|
||||||
|
return Mono.just(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert the DSL into a String
|
||||||
try {
|
try {
|
||||||
dslString = objectMapper.writeValueAsString(dsl);
|
dslString = objectMapper.writeValueAsString(dsl);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
|
|
@ -199,7 +204,12 @@ public class LayoutActionServiceImpl implements LayoutActionService {
|
||||||
.save(action)
|
.save(action)
|
||||||
.flatMap(savedAction -> pageService
|
.flatMap(savedAction -> pageService
|
||||||
.findById(oldPageId)
|
.findById(oldPageId)
|
||||||
.map(page -> page.getLayouts()
|
.map(page -> {
|
||||||
|
if (page.getLayouts() == null) {
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return page.getLayouts()
|
||||||
.stream()
|
.stream()
|
||||||
/*
|
/*
|
||||||
* subscribe() is being used here because within a stream, the master subscriber provided
|
* subscribe() is being used here because within a stream, the master subscriber provided
|
||||||
|
|
@ -207,12 +217,19 @@ public class LayoutActionServiceImpl implements LayoutActionService {
|
||||||
* emitting. The same is true for the updateLayout call for the new page.
|
* emitting. The same is true for the updateLayout call for the new page.
|
||||||
*/
|
*/
|
||||||
.map(layout -> updateLayout(oldPageId, layout.getId(), layout).subscribe())
|
.map(layout -> updateLayout(oldPageId, layout.getId(), layout).subscribe())
|
||||||
.collect(toSet()))
|
.collect(toSet());
|
||||||
|
})
|
||||||
.then(pageService.findById(actionMoveDTO.getDestinationPageId()))
|
.then(pageService.findById(actionMoveDTO.getDestinationPageId()))
|
||||||
.map(page -> page.getLayouts()
|
.map(page -> {
|
||||||
|
if (page.getLayouts() == null) {
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
return page.getLayouts()
|
||||||
.stream()
|
.stream()
|
||||||
.map(layout -> updateLayout(actionMoveDTO.getDestinationPageId(), layout.getId(), layout).subscribe())
|
.map(layout -> updateLayout(actionMoveDTO.getDestinationPageId(), layout.getId(), layout).subscribe())
|
||||||
.collect(toSet()))
|
.collect(toSet());
|
||||||
|
})
|
||||||
.thenReturn(savedAction));
|
.thenReturn(savedAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user