use of org.codelibs.fess.exception.FessSystemException in project fess by codelibs.
the class ApiAdminElevatewordAction method post$upload.
// POST /api/admin/elevateword/upload
@Execute
public JsonResponse<ApiResult> post$upload(final UploadForm body) {
validateApi(body, messages -> {
});
CommonPoolUtil.execute(() -> {
try (Reader reader = new BufferedReader(new InputStreamReader(body.elevateWordFile.getInputStream(), getCsvEncoding()))) {
elevateWordService.importCsv(reader);
suggestHelper.storeAllElevateWords(false);
} catch (final Exception e) {
throw new FessSystemException("Failed to import data.", e);
}
});
return asJson(new ApiResult.ApiResponse().status(ApiResult.Status.OK).result());
}
use of org.codelibs.fess.exception.FessSystemException in project fess by codelibs.
the class AdminElevatewordAction method upload.
@Execute
@Secured({ ROLE })
public HtmlResponse upload(final UploadForm form) {
validate(form, messages -> {
}, this::asUploadHtml);
verifyToken(this::asUploadHtml);
CommonPoolUtil.execute(() -> {
try (Reader reader = new BufferedReader(new InputStreamReader(form.elevateWordFile.getInputStream(), getCsvEncoding()))) {
elevateWordService.importCsv(reader);
suggestHelper.deleteAllElevateWord(false);
suggestHelper.storeAllElevateWords(false);
} catch (final Exception e) {
throw new FessSystemException("Failed to import data.", e);
}
});
saveInfo(messages -> messages.addSuccessUploadElevateWord(GLOBAL));
return redirect(getClass());
}
use of org.codelibs.fess.exception.FessSystemException in project fess by codelibs.
the class AdminLogAction method getLogFileItems.
public static List<Map<String, Object>> getLogFileItems() {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final List<Map<String, Object>> logFileItems = new ArrayList<>();
final String logFilePath = systemHelper.getLogFilePath();
if (StringUtil.isNotBlank(logFilePath)) {
final Path logDirPath = Paths.get(logFilePath);
try (Stream<Path> stream = Files.list(logDirPath)) {
stream.filter(entry -> isLogFilename(entry.getFileName().toString())).sorted().forEach(filePath -> {
final Map<String, Object> map = new HashMap<>();
final String name = filePath.getFileName().toString();
map.put("id", Base64.getUrlEncoder().encodeToString(name.getBytes(StandardCharsets.UTF_8)));
map.put("name", name);
try {
map.put("lastModified", new Date(Files.getLastModifiedTime(filePath).toMillis()));
} catch (final IOException e) {
throw new IORuntimeException(e);
}
logFileItems.add(map);
});
} catch (final Exception e) {
throw new FessSystemException("Failed to access log files.", e);
}
}
return logFileItems;
}
Aggregations