use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class LdapManager method processSearchRoles.
protected void processSearchRoles(final List<SearchResult> result, final BiConsumer<String, String> consumer) throws NamingException {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
for (final SearchResult srcrslt : result) {
final Attributes attrs = srcrslt.getAttributes();
//get group attr
final Attribute attr = attrs.get(fessConfig.getLdapMemberofAttribute());
if (attr == null) {
continue;
}
for (int i = 0; i < attr.size(); i++) {
final Object attrValue = attr.get(i);
if (attrValue != null) {
final String entryDn = attrValue.toString();
int start = 0;
int end = 0;
start = entryDn.indexOf("CN=");
if (start < 0) {
start = entryDn.indexOf("cn=");
}
if (start == -1) {
continue;
}
start += 3;
end = entryDn.indexOf(',');
String name;
if (end == -1) {
name = entryDn.substring(start);
} else {
name = entryDn.substring(start, end);
}
consumer.accept(entryDn, name);
}
}
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class IndexUpdater method updateDocument.
protected void updateDocument(final Map<String, Object> map) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (fessConfig.getIndexerClickCountEnabledAsBoolean()) {
addClickCountField(map);
}
if (fessConfig.getIndexerFavoriteCountEnabledAsBoolean()) {
addFavoriteCountField(map);
}
float documentBoost = 0.0f;
for (final DocBoostMatcher docBoostMatcher : docBoostMatcherList) {
if (docBoostMatcher.match(map)) {
documentBoost = docBoostMatcher.getValue(map);
break;
}
}
if (documentBoost > 0) {
addBoostValue(map, documentBoost);
}
if (!map.containsKey(fessConfig.getIndexFieldDocId())) {
map.put(fessConfig.getIndexFieldDocId(), systemHelper.generateDocId(map));
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class IndexUpdater method getAccessResultList.
private List<EsAccessResult> getAccessResultList(final Consumer<SearchRequestBuilder> cb, final long cleanupTime) {
if (logger.isDebugEnabled()) {
logger.debug("Getting documents in IndexUpdater queue.");
}
final long execTime = System.currentTimeMillis();
final List<EsAccessResult> arList = ((EsDataService) dataService).getAccessResultList(cb);
final FessConfig fessConfig = ComponentUtil.getFessConfig();
if (!arList.isEmpty()) {
final long commitMarginTime = fessConfig.getIndexerWebfsCommitMarginTimeAsInteger().longValue();
for (final AccessResult<?> ar : arList.toArray(new AccessResult[arList.size()])) {
if (ar.getCreateTime().longValue() > execTime - commitMarginTime) {
arList.remove(ar);
}
}
}
final long totalHits = ((EsResultList<EsAccessResult>) arList).getTotalHits();
if (logger.isInfoEnabled()) {
final StringBuilder buf = new StringBuilder(100);
buf.append("Processing ");
if (totalHits > 0) {
buf.append(arList.size()).append('/').append(totalHits).append(" docs (Doc:{access ");
} else {
buf.append("no docs (Doc:{access ");
}
buf.append(System.currentTimeMillis() - execTime).append("ms");
if (cleanupTime >= 0) {
buf.append(", cleanup ").append(cleanupTime).append("ms");
}
buf.append("}, ");
buf.append(MemoryUtil.getMemoryUsageLog());
buf.append(')');
logger.info(buf.toString());
}
final long unprocessedDocumentSize = fessConfig.getIndexerUnprocessedDocumentSizeAsInteger().longValue();
final IntervalControlHelper intervalControlHelper = ComponentUtil.getIntervalControlHelper();
if (totalHits > unprocessedDocumentSize && intervalControlHelper.isCrawlerRunning()) {
if (logger.isInfoEnabled()) {
logger.info("Stopped all crawler threads. " + " You have " + totalHits + " (>" + unprocessedDocumentSize + ") " + " unprocessed docs.");
}
intervalControlHelper.setCrawlerRunning(false);
}
return arList;
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class IndexUpdater method addFavoriteCountField.
protected void addFavoriteCountField(final Map<String, Object> map) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final String url = (String) map.get(fessConfig.getIndexFieldUrl());
if (StringUtil.isNotBlank(url)) {
final SearchLogHelper searchLogHelper = ComponentUtil.getSearchLogHelper();
final long count = searchLogHelper.getFavoriteCount(url);
map.put(fessConfig.getIndexFieldFavoriteCount(), count);
if (logger.isDebugEnabled()) {
logger.debug("Favorite Count: " + count + ", url: " + url);
}
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class SystemHelper method init.
@PostConstruct
public void init() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
filterPathEncoding = fessConfig.getPathEncoding();
supportedLanguages = fessConfig.getSupportedLanguagesAsArray();
langItemsCache = CacheBuilder.newBuilder().maximumSize(20).expireAfterAccess(1, TimeUnit.HOURS).build(new CacheLoader<String, List<Map<String, String>>>() {
@Override
public List<Map<String, String>> load(final String key) throws Exception {
final ULocale uLocale = new ULocale(key);
final Locale displayLocale = uLocale.toLocale();
final List<Map<String, String>> langItems = new ArrayList<>(supportedLanguages.length);
final String msg = ComponentUtil.getMessageManager().getMessage(displayLocale, "labels.allLanguages");
final Map<String, String> defaultMap = new HashMap<>(2);
defaultMap.put(Constants.ITEM_LABEL, msg);
defaultMap.put(Constants.ITEM_VALUE, "all");
langItems.add(defaultMap);
for (final String lang : supportedLanguages) {
final Locale locale = LocaleUtils.toLocale(lang);
final String label = locale.getDisplayName(displayLocale);
final Map<String, String> map = new HashMap<>(2);
map.put(Constants.ITEM_LABEL, label);
map.put(Constants.ITEM_VALUE, lang);
langItems.add(map);
}
return langItems;
}
});
ComponentUtil.doInitProcesses(p -> p.run());
}
Aggregations