Non-null check for updateResourcesUsage
This commit is contained in:
parent
f50789ebf3
commit
a2ae5b06c0
@ -50,7 +50,8 @@ public class WidgetType extends BaseWidgetType {
|
|||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public JsonNode getDefaultConfig() {
|
public JsonNode getDefaultConfig() {
|
||||||
return Optional.ofNullable(descriptor.get("defaultConfig"))
|
return Optional.ofNullable(descriptor)
|
||||||
|
.map(descriptor -> descriptor.get("defaultConfig"))
|
||||||
.filter(JsonNode::isTextual).map(JsonNode::asText)
|
.filter(JsonNode::isTextual).map(JsonNode::asText)
|
||||||
.map(json -> {
|
.map(json -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -403,6 +403,9 @@ public class BaseResourceService extends AbstractCachedEntityService<ResourceInf
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateResourcesUsage(TenantId tenantId, Dashboard dashboard) {
|
public boolean updateResourcesUsage(TenantId tenantId, Dashboard dashboard) {
|
||||||
|
if (dashboard.getConfiguration() == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Map<String, String> links = getResourcesLinks(dashboard.getResources());
|
Map<String, String> links = getResourcesLinks(dashboard.getResources());
|
||||||
return updateResourcesUsage(tenantId, List.of(dashboard.getConfiguration()), List.of(DASHBOARD_RESOURCES_MAPPING), links);
|
return updateResourcesUsage(tenantId, List.of(dashboard.getConfiguration()), List.of(DASHBOARD_RESOURCES_MAPPING), links);
|
||||||
}
|
}
|
||||||
@ -413,8 +416,10 @@ public class BaseResourceService extends AbstractCachedEntityService<ResourceInf
|
|||||||
List<JsonNode> jsonNodes = new ArrayList<>(2);
|
List<JsonNode> jsonNodes = new ArrayList<>(2);
|
||||||
List<Map<String, String>> mappings = new ArrayList<>(2);
|
List<Map<String, String>> mappings = new ArrayList<>(2);
|
||||||
|
|
||||||
jsonNodes.add(widgetTypeDetails.getDescriptor());
|
if (widgetTypeDetails.getDescriptor() != null) {
|
||||||
mappings.add(WIDGET_RESOURCES_MAPPING);
|
jsonNodes.add(widgetTypeDetails.getDescriptor());
|
||||||
|
mappings.add(WIDGET_RESOURCES_MAPPING);
|
||||||
|
}
|
||||||
|
|
||||||
JsonNode defaultConfig = widgetTypeDetails.getDefaultConfig();
|
JsonNode defaultConfig = widgetTypeDetails.getDefaultConfig();
|
||||||
if (defaultConfig != null) {
|
if (defaultConfig != null) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user