use of jetbrains.buildServer.serverSide.impl.ErrorMessageSanitizer in project teamcity-git by JetBrains.
the class GitGcErrorsHealthPage method fillModel.
@Override
public void fillModel(@NotNull final Map<String, Object> model, @NotNull final HttpServletRequest request) {
HealthStatusItem item = getStatusItem(request);
Object errors = item.getAdditionalData().get(GitGcErrorsHealthReport.ERRORS_KEY);
Map<String, Pair<String, String>> sortedErrors = new TreeMap<>();
if (errors instanceof Map) {
File mainDataDirectory;
try {
mainDataDirectory = myServerPaths.getDataDirectory().getCanonicalFile();
} catch (IOException e) {
mainDataDirectory = myServerPaths.getDataDirectory().getAbsoluteFile();
}
ErrorMessageSanitizer errorMessageSanitizer = new ErrorMessageSanitizer(mainDataDirectory.getAbsolutePath(), "<TeamCity Data Directory>");
File currentNodeDataDir = NodeSpecificConfigs.getNodeDataDirectory(mainDataDirectory);
errorMessageSanitizer.addSanitizedPath(currentNodeDataDir.getAbsolutePath(), "<Node Data Directory>");
// noinspection unchecked
Set<Map.Entry> entries = ((Map) errors).entrySet();
for (Map.Entry entry : entries) {
Object key = entry.getKey();
Object value = entry.getValue();
if (key instanceof File && value instanceof String) {
try {
String url = myMirrorManager.getUrl(((File) key).getName());
if (url != null) {
sortedErrors.put(url, Pair.create(errorMessageSanitizer.sanitize(((File) key).getCanonicalPath()), (String) value));
}
} catch (IOException e) {
LOG.warnAndDebugDetails("Error while preparing health report data", e);
}
}
}
}
model.put("errors", sortedErrors);
}
Aggregations