use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AdminElevatewordAction method getElevateWord.
public static OptionalEntity<ElevateWord> getElevateWord(final CreateForm form) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
BeanUtil.copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS)).toArray(n -> new String[n])));
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
entity.setPermissions(split(form.permissions, "\n").get(stream -> stream.map(permissionHelper::encode).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.fess.helper.SystemHelper 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;
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AdminGeneralAction method updateConfig.
public static void updateConfig(final FessConfig fessConfig, final EditForm form) {
fessConfig.setLoginRequired(isCheckboxEnabled(form.loginRequired));
fessConfig.setResultCollapsed(isCheckboxEnabled(form.resultCollapsed));
fessConfig.setLoginLinkEnabled(isCheckboxEnabled(form.loginLink));
fessConfig.setThumbnailEnabled(isCheckboxEnabled(form.thumbnail));
fessConfig.setIncrementalCrawling(isCheckboxEnabled(form.incrementalCrawling));
fessConfig.setDayForCleanup(form.dayForCleanup);
fessConfig.setCrawlingThreadCount(form.crawlingThreadCount);
fessConfig.setSearchLog(isCheckboxEnabled(form.searchLog));
fessConfig.setUserInfo(isCheckboxEnabled(form.userInfo));
fessConfig.setUserFavorite(isCheckboxEnabled(form.userFavorite));
fessConfig.setWebApiJson(isCheckboxEnabled(form.webApiJson));
fessConfig.setAppValue(form.appValue);
fessConfig.setDefaultLabelValue(form.defaultLabelValue);
fessConfig.setDefaultSortValue(form.defaultSortValue);
fessConfig.setVirtualHostValue(form.virtualHostValue);
fessConfig.setAppendQueryParameter(isCheckboxEnabled(form.appendQueryParameter));
fessConfig.setIgnoreFailureType(form.ignoreFailureType);
fessConfig.setFailureCountThreshold(form.failureCountThreshold);
fessConfig.setWebApiPopularWord(isCheckboxEnabled(form.popularWord));
fessConfig.setCsvFileEncoding(form.csvFileEncoding);
fessConfig.setPurgeSearchLogDay(form.purgeSearchLogDay);
fessConfig.setPurgeJobLogDay(form.purgeJobLogDay);
fessConfig.setPurgeUserInfoDay(form.purgeUserInfoDay);
fessConfig.setPurgeByBots(form.purgeByBots);
fessConfig.setNotificationTo(form.notificationTo);
fessConfig.setSuggestSearchLog(isCheckboxEnabled(form.suggestSearchLog));
fessConfig.setSuggestDocuments(isCheckboxEnabled(form.suggestDocuments));
fessConfig.setPurgeSuggestSearchLogDay(form.purgeSuggestSearchLogDay);
fessConfig.setLdapProviderUrl(form.ldapProviderUrl);
fessConfig.setLdapSecurityPrincipal(form.ldapSecurityPrincipal);
fessConfig.setLdapAdminSecurityPrincipal(form.ldapAdminSecurityPrincipal);
if (form.ldapAdminSecurityCredentials != null && StringUtil.isNotBlank(form.ldapAdminSecurityCredentials.replace("*", " "))) {
fessConfig.setLdapAdminSecurityCredentials(form.ldapAdminSecurityCredentials);
}
fessConfig.setLdapBaseDn(form.ldapBaseDn);
fessConfig.setLdapAccountFilter(form.ldapAccountFilter);
fessConfig.setLdapGroupFilter(form.ldapGroupFilter);
fessConfig.setLdapMemberofAttribute(form.ldapMemberofAttribute);
fessConfig.setNotificationLogin(form.notificationLogin);
fessConfig.setNotificationSearchTop(form.notificationSearchTop);
fessConfig.setStorageEndpoint(form.storageEndpoint);
if (form.storageAccessKey != null && StringUtil.isNotBlank(form.storageAccessKey.replace("*", " "))) {
fessConfig.setStorageAccessKey(form.storageAccessKey);
}
if (form.storageSecretKey != null && StringUtil.isNotBlank(form.storageSecretKey.replace("*", " "))) {
fessConfig.setStorageSecretKey(form.storageSecretKey);
}
fessConfig.setStorageBucket(form.storageBucket);
fessConfig.storeSystemProperties();
ComponentUtil.getLdapManager().updateConfig();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
systemHelper.refreshDesignJspFiles();
systemHelper.updateSystemProperties();
if (StringUtil.isNotBlank(form.logLevel)) {
systemHelper.setLogLevel(form.logLevel);
}
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AdminRelatedqueryAction method getRelatedQuery.
public static OptionalEntity<RelatedQuery> getRelatedQuery(final CreateForm form) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
BeanUtil.copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.QUERIES)).toArray(n -> new String[n])));
entity.setQueries(split(form.queries, "\n").get(stream -> stream.filter(StringUtil::isNotBlank).toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AdminSearchlistAction method getDoc.
public static OptionalEntity<Map<String, Object>> getDoc(final CreateForm form) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final SearchEngineClient searchEngineClient = ComponentUtil.getSearchEngineClient();
switch(form.crudMode) {
case CrudMode.CREATE:
final Map<String, Object> entity = new HashMap<>();
entity.put(fessConfig.getIndexFieldDocId(), systemHelper.generateDocId(entity));
return OptionalEntity.of(entity);
case CrudMode.EDIT:
final String docId;
if (form.doc != null) {
docId = (String) form.doc.get(fessConfig.getIndexFieldDocId());
} else {
docId = null;
}
if (StringUtil.isNotBlank(docId)) {
return searchEngineClient.getDocument(fessConfig.getIndexDocumentUpdateIndex(), builder -> {
builder.setQuery(QueryBuilders.termQuery(fessConfig.getIndexFieldDocId(), docId));
return true;
});
}
break;
default:
break;
}
return OptionalEntity.empty();
}
Aggregations