|
15 | 15 | import static org.lowcoder.sdk.util.ExceptionUtils.ofError;
|
16 | 16 |
|
17 | 17 | import java.time.Instant;
|
18 |
| -import java.util.HashSet; |
19 |
| -import java.util.List; |
20 |
| -import java.util.Map; |
21 |
| -import java.util.Set; |
| 18 | +import java.util.*; |
22 | 19 | import java.util.stream.Collectors;
|
23 | 20 |
|
24 | 21 | import javax.annotation.Nonnull;
|
@@ -366,8 +363,8 @@ public Mono<ApplicationView> publish(String applicationId) {
|
366 | 363 | }
|
367 | 364 |
|
368 | 365 | public Mono<Boolean> grantPermission(String applicationId,
|
369 |
| - Set<String> userIds, |
370 |
| - Set<String> groupIds, ResourceRole role) { |
| 366 | + Set<String> userIds, |
| 367 | + Set<String> groupIds, ResourceRole role) { |
371 | 368 | if (userIds.isEmpty() && groupIds.isEmpty()) {
|
372 | 369 | return Mono.just(true);
|
373 | 370 | }
|
@@ -502,11 +499,48 @@ private Map<String, Object> sanitizeDsl(Map<String, Object> applicationDsl) {
|
502 | 499 | if (applicationDsl.get("queries") instanceof List<?> queries) {
|
503 | 500 | List<Map<String, Object>> list = queries.stream().map(this::doSanitizeQuery).toList();
|
504 | 501 | applicationDsl.put("queries", list);
|
| 502 | + removeTestVariablesFromProductionView(applicationDsl); |
505 | 503 | return applicationDsl;
|
506 | 504 | }
|
| 505 | + removeTestVariablesFromProductionView(applicationDsl); |
507 | 506 | return applicationDsl;
|
508 | 507 | }
|
509 | 508 |
|
| 509 | + private void removeTestVariablesFromProductionView(Map<String, Object> applicationDsl) { |
| 510 | + /**Remove "test" object if it exists within "applicationDSL**/ |
| 511 | + if (applicationDsl.containsKey("ui")) { |
| 512 | + Map<String, Object> dataObject = (Map<String, Object>) applicationDsl.get("ui"); |
| 513 | + if (dataObject.containsKey("comp")) { |
| 514 | + Map<String, Object> applicationDSL = (Map<String, Object>) dataObject.get("comp"); |
| 515 | + doRemoveTestVariablesFromProductionView(applicationDSL); |
| 516 | + } |
| 517 | + } |
| 518 | + } |
| 519 | + |
| 520 | + private void doRemoveTestVariablesFromProductionView(Map<String, Object> map) { |
| 521 | + if (map.containsKey("io")) { |
| 522 | + Map<String, Object> io = (Map<String, Object>) map.get("io"); |
| 523 | + if (io.containsKey("inputs")) { |
| 524 | + List<Map<String, Object>> inputs = (List<Map<String, Object>>) io.get("inputs"); |
| 525 | + for (Map<String, Object> inputMap : inputs) { |
| 526 | + if (inputMap.containsKey("test")) { |
| 527 | + inputMap.remove("test"); |
| 528 | + } |
| 529 | + } |
| 530 | + } |
| 531 | + |
| 532 | + if (io.containsKey("outputs")) { |
| 533 | + List<Map<String, Object>> outputs = (List<Map<String, Object>>) io.get("outputs"); |
| 534 | + for (Map<String, Object> inputMap : outputs) { |
| 535 | + if (inputMap.containsKey("test")) { |
| 536 | + inputMap.remove("test"); |
| 537 | + } |
| 538 | + } |
| 539 | + } |
| 540 | + } |
| 541 | + } |
| 542 | + |
| 543 | + |
510 | 544 | @SuppressWarnings("unchecked")
|
511 | 545 | private Map<String, Object> doSanitizeQuery(Object query) {
|
512 | 546 | if (!(query instanceof Map)) {
|
|
0 commit comments