Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -99,6 +101,7 @@ protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHtt
}

private DataSource buildDataSource(final ResourceResolver rr, final ConversionJobBucket bucket, int offset, int limit) {
Map<String, List<String>> warningsByPath = parseWarnings(bucket);
List<Resource> entries = bucket.getPaths().stream().skip(offset).limit(limit).map(p -> {
Map<String, Object> vm = new HashMap<>();
vm.put("path", p);
Expand All @@ -118,10 +121,31 @@ private DataSource buildDataSource(final ResourceResolver rr, final ConversionJo
vm.put("status", "Unknown");
vm.put("statusClass", "unknown");
vm.put("icon", "helpCircle");

}
List<String> warns = warningsByPath.getOrDefault(p, Collections.emptyList());
if (!warns.isEmpty()) {
vm.put("warnings", true);
vm.put("warningList", warns.toArray(new String[0]));
}
return new ValueMapResource(rr, p, ITEM_RESOURCE_TYPE, new ValueMapDecorator(vm));
}).collect(Collectors.toList());
return new SimpleDataSource(entries.iterator());
}

private Map<String, List<String>> parseWarnings(ConversionJobBucket bucket) {
String[] raw = bucket.getResource().getValueMap().get("warnings", new String[0]);
if (raw.length == 0) {
return Collections.emptyMap();
}
Map<String, List<String>> result = new HashMap<>();
for (String entry : raw) {
int sep = entry.indexOf("||");
if (sep > 0) {
String path = entry.substring(0, sep);
String msg = entry.substring(sep + 2);
result.computeIfAbsent(path, k -> new ArrayList<>()).add(msg);
}
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
#L%
-->
<tr is="coral-table-row" title="${properties.path}" class="foundation-collection-item">
<td is="coral-table-cell">${properties.path}</td>
<td is="coral-table-cell">
<div>${properties.path}</div>
<sly data-sly-test="${properties.warnings}">
<sly data-sly-list.warning="${properties.warningList}">
<div style="font-size:11px;color:#d7373f;margin-top:2px;">&#x26A0; ${warning}</div>
</sly>
</sly>
</td>
<td is="coral-table-cell" value="${properties.status}">${properties.status}</td>
<td is="coral-table-cell">
<div class="mediumIcon ${properties.statusClass}">
Expand Down