use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class FailureUrlService method getStackTrace.
private String getStackTrace(final Throwable t) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final StringBuilderWriter sw = new StringBuilderWriter();
final PrintWriter pw = new PrintWriter(sw, true);
t.printStackTrace(pw);
return systemHelper.abbreviateLongText(sw.toString());
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AdminWebconfigAction method getWebConfig.
public static OptionalEntity<WebConfig> getWebConfig(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);
copyBeanToBean(form, entity, op -> op.exclude(Stream.concat(Stream.of(Constants.COMMON_CONVERSION_RULE), Stream.of(Constants.PERMISSIONS, Constants.VIRTUAL_HOSTS)).toArray(n -> new String[n])));
final PermissionHelper permissionHelper = ComponentUtil.getPermissionHelper();
entity.setPermissions(split(form.permissions, "\n").get(stream -> stream.map(s -> permissionHelper.encode(s)).filter(StringUtil::isNotBlank).distinct().toArray(n -> new String[n])));
entity.setVirtualHosts(split(form.virtualHosts, "\n").get(stream -> stream.filter(StringUtil::isNotBlank).distinct().map(String::trim).toArray(n -> new String[n])));
return entity;
});
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class FileConfig method initDocPathPattern.
protected synchronized void initDocPathPattern() {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
if (includedDocPathPatterns == null) {
if (StringUtil.isNotBlank(getIncludedDocPaths())) {
final List<Pattern> pathPatterList = new ArrayList<>();
final String[] paths = getIncludedDocPaths().split("[\r\n]");
for (final String u : paths) {
final String v = systemHelper.normalizeConfigPath(u);
if (StringUtil.isNotBlank(v)) {
pathPatterList.add(Pattern.compile(systemHelper.encodeUrlFilter(v)));
}
}
includedDocPathPatterns = pathPatterList.toArray(new Pattern[pathPatterList.size()]);
} else {
includedDocPathPatterns = new Pattern[0];
}
}
if (excludedDocPathPatterns == null) {
if (StringUtil.isNotBlank(getExcludedDocPaths())) {
final List<Pattern> pathPatterList = new ArrayList<>();
final String[] paths = getExcludedDocPaths().split("[\r\n]");
for (final String u : paths) {
final String v = systemHelper.normalizeConfigPath(u);
if (StringUtil.isNotBlank(v)) {
pathPatterList.add(Pattern.compile(systemHelper.encodeUrlFilter(v)));
}
}
excludedDocPathPatterns = pathPatterList.toArray(new Pattern[pathPatterList.size()]);
} else if (includedDocPathPatterns.length > 0) {
excludedDocPathPatterns = new Pattern[] { Pattern.compile(".*") };
} else {
excludedDocPathPatterns = new Pattern[0];
}
}
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class ThumbnailManager method storeQueue.
protected void storeQueue(final List<Tuple3<String, String, String>> taskList) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final String[] targets = fessConfig.getThumbnailGeneratorTargetsAsArray();
final List<ThumbnailQueue> list = new ArrayList<>();
taskList.stream().filter(entity -> entity != null).forEach(task -> {
for (final String target : targets) {
final ThumbnailQueue entity = new ThumbnailQueue();
entity.setGenerator(task.getValue1());
entity.setThumbnailId(task.getValue2());
entity.setPath(task.getValue3());
entity.setTarget(target);
entity.setCreatedBy(Constants.SYSTEM_USER);
entity.setCreatedTime(systemHelper.getCurrentTimeAsLong());
list.add(entity);
}
});
taskList.clear();
if (logger.isDebugEnabled()) {
logger.debug("Storing {} thumbnail tasks.", list.size());
}
final ThumbnailQueueBhv thumbnailQueueBhv = ComponentUtil.getComponent(ThumbnailQueueBhv.class);
thumbnailQueueBhv.batchInsert(list);
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class AbstractDataStore method store.
@Override
public void store(final DataConfig config, final IndexUpdateCallback callback, final Map<String, String> initParamMap) {
final CrawlingInfoHelper crawlingInfoHelper = ComponentUtil.getCrawlingInfoHelper();
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final Date documentExpires = crawlingInfoHelper.getDocumentExpires(config);
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final Map<String, String> paramEnvMap = systemHelper.getFilteredEnvMap(fessConfig.getCrawlerDataEnvParamKeyPattern());
final Map<String, String> configParamMap = config.getHandlerParameterMap().entrySet().stream().map(e -> {
final String key = e.getKey();
String value = e.getValue();
for (final Map.Entry<String, String> entry : paramEnvMap.entrySet()) {
value = value.replace("${" + entry.getKey() + "}", entry.getValue());
}
return new Pair<>(key, value);
}).collect(Collectors.toMap(Pair<String, String>::getFirst, Pair<String, String>::getSecond));
final Map<String, String> configScriptMap = config.getHandlerScriptMap();
initParamMap.putAll(configParamMap);
final Map<String, String> paramMap = initParamMap;
// default values
final Map<String, Object> defaultDataMap = new HashMap<>();
// cid
final String configId = config.getConfigId();
if (configId != null) {
defaultDataMap.put(fessConfig.getIndexFieldConfigId(), configId);
}
// expires
if (documentExpires != null) {
defaultDataMap.put(fessConfig.getIndexFieldExpires(), documentExpires);
}
// segment
defaultDataMap.put(fessConfig.getIndexFieldSegment(), initParamMap.get(Constants.SESSION_ID));
// created
defaultDataMap.put(fessConfig.getIndexFieldCreated(), systemHelper.getCurrentTime());
// boost
defaultDataMap.put(fessConfig.getIndexFieldBoost(), config.getBoost().toString());
// label: labelType
// role: roleType
final List<String> roleTypeList = new ArrayList<>();
stream(config.getPermissions()).of(stream -> stream.forEach(p -> roleTypeList.add(p)));
defaultDataMap.put(fessConfig.getIndexFieldRole(), roleTypeList);
// mimetype
defaultDataMap.put(fessConfig.getIndexFieldMimetype(), mimeType);
// title
// content
// cache
// digest
// host
// site
// url
// anchor
// content_length
// last_modified
// id
// virtual_host
defaultDataMap.put(fessConfig.getIndexFieldVirtualHost(), stream(config.getVirtualHosts()).get(stream -> stream.filter(StringUtil::isNotBlank).collect(Collectors.toList())));
storeData(config, callback, new ParamMap<>(paramMap), configScriptMap, defaultDataMap);
}
Aggregations