use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class PurgeLogJob method execute.
public String execute() {
final CrawlingInfoService crawlingInfoService = ComponentUtil.getComponent(CrawlingInfoService.class);
final SearchLogService searchLogService = ComponentUtil.getComponent(SearchLogService.class);
final JobLogService jobLogService = ComponentUtil.getComponent(JobLogService.class);
final UserInfoService userInfoService = ComponentUtil.getComponent(UserInfoService.class);
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final StringBuilder resultBuf = new StringBuilder();
// purge crawling sessions
try {
crawlingInfoService.deleteBefore(systemHelper.getCurrentTimeAsLong());
} catch (final Exception e) {
logger.error("Failed to purge crawling sessions.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge search logs
try {
final int days = ComponentUtil.getFessConfig().getPurgeSearchLogDay();
if (days >= 0) {
searchLogService.deleteBefore(days);
} else {
resultBuf.append("Skipped to purge search logs.\n");
}
} catch (final Exception e) {
logger.error("Failed to purge search logs.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge job logs
try {
final int days = ComponentUtil.getFessConfig().getPurgeJobLogDay();
if (days >= 0) {
jobLogService.deleteBefore(days);
} else {
resultBuf.append("Skipped to purge job logs.\n");
}
} catch (final Exception e) {
logger.error("Failed to purge job logs.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// purge user info
try {
final int days = ComponentUtil.getFessConfig().getPurgeUserInfoDay();
if (days >= 0) {
userInfoService.deleteBefore(days);
} else {
resultBuf.append("Skipped to purge user info logs.\n");
}
} catch (final Exception e) {
logger.error("Failed to purge user info.", e);
resultBuf.append(e.getMessage()).append("\n");
}
// update job logs
try {
jobLogService.updateStatus();
} catch (final Exception e) {
logger.error("Failed to purge job logs.", e);
resultBuf.append(e.getMessage()).append("\n");
}
return resultBuf.toString();
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class LdapManager method getRoles.
public String[] getRoles(final LdapUser ldapUser, final String bindDn, final String accountFilter) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final List<String> roleList = new ArrayList<>();
if (fessConfig.isLdapRoleSearchUserEnabled()) {
roleList.add(systemHelper.getSearchRoleByUser(ldapUser.getName()));
}
// LDAP: cn=%s
// AD: (&(objectClass=user)(sAMAccountName=%s))
final String filter = String.format(accountFilter, ldapUser.getName());
search(bindDn, filter, new String[] { fessConfig.getLdapMemberofAttribute() }, () -> ldapUser.getEnvironment(), result -> {
processSearchRoles(result, (entryDn, name) -> {
final boolean isRole = entryDn.toLowerCase(Locale.ROOT).indexOf("ou=role") != -1;
if (isRole) {
if (fessConfig.isLdapRoleSearchRoleEnabled()) {
roleList.add(systemHelper.getSearchRoleByRole(name));
}
} else if (fessConfig.isLdapRoleSearchGroupEnabled()) {
roleList.add(systemHelper.getSearchRoleByGroup(name));
}
});
});
return roleList.toArray(new String[roleList.size()]);
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class ThumbnailManager method storeQueue.
protected void storeQueue(final List<Tuple4<String, 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.setUrl(task.getValue3());
entity.setPath(task.getValue4());
entity.setTarget(target);
entity.setCreatedBy(Constants.SYSTEM_USER);
entity.setCreatedTime(systemHelper.getCurrentTimeAsLong());
list.add(entity);
}
});
taskList.clear();
final ThumbnailQueueBhv thumbnailQueueBhv = ComponentUtil.getComponent(ThumbnailQueueBhv.class);
thumbnailQueueBhv.batchInsert(list);
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class GitBucketDataStoreImpl method createRoleList.
private List<String> createRoleList(final String owner, final Map<String, Object> repository) {
Boolean isPrivate = true;
if (repository.containsKey(PRIVATE_REPOSITORY_PARAM)) {
isPrivate = (Boolean) repository.get(PRIVATE_REPOSITORY_PARAM);
}
if (!isPrivate) {
return Collections.singletonList("Rguest");
}
@SuppressWarnings("unchecked") final List<String> collaboratorList = (List<String>) repository.get(COLLABORATORS_PARAM);
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
collaboratorList.add(owner);
return collaboratorList.stream().map(user -> systemHelper.getSearchRoleByUser(user)).collect(Collectors.toList());
}
use of org.codelibs.fess.helper.SystemHelper in project fess by codelibs.
the class IndexUpdateCallbackImpl method store.
/* (non-Javadoc)
* @see org.codelibs.fess.ds.impl.IndexUpdateCallback#store(java.util.Map)
*/
@Override
public void store(final Map<String, String> paramMap, final Map<String, Object> dataMap) {
final long startTime = System.currentTimeMillis();
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final FessEsClient fessEsClient = ComponentUtil.getFessEsClient();
if (logger.isDebugEnabled()) {
logger.debug("Adding " + dataMap);
}
// required check
final Object urlObj = dataMap.get(fessConfig.getIndexFieldUrl());
if (urlObj == null) {
throw new DataStoreException("url is null. dataMap=" + dataMap);
}
final IndexingHelper indexingHelper = ComponentUtil.getIndexingHelper();
final CrawlingInfoHelper crawlingInfoHelper = ComponentUtil.getCrawlingInfoHelper();
dataMap.put(fessConfig.getIndexFieldId(), crawlingInfoHelper.generateId(dataMap));
final String url = dataMap.get(fessConfig.getIndexFieldUrl()).toString();
if (fessConfig.getIndexerClickCountEnabledAsBoolean()) {
addClickCountField(dataMap, url, fessConfig.getIndexFieldClickCount());
}
if (fessConfig.getIndexerFavoriteCountEnabledAsBoolean()) {
addFavoriteCountField(dataMap, url, fessConfig.getIndexFieldFavoriteCount());
}
if (!dataMap.containsKey(fessConfig.getIndexFieldDocId())) {
final SystemHelper systemHelper = ComponentUtil.getSystemHelper();
dataMap.put(fessConfig.getIndexFieldDocId(), systemHelper.generateDocId(dataMap));
}
synchronized (docList) {
docList.add(dataMap);
if (logger.isDebugEnabled()) {
logger.debug("Added the document. " + "The number of a document cache is " + docList.size() + ".");
}
final Long contentLength = DocumentUtil.getValue(dataMap, fessConfig.getIndexFieldContentLength(), Long.class);
if (contentLength != null) {
docList.addContentSize(contentLength.longValue());
if (docList.getContentSize() >= maxDocumentRequestSize) {
indexingHelper.sendDocuments(fessEsClient, docList);
}
} else if (docList.size() >= fessConfig.getIndexerDataMaxDocumentCacheSizeAsInteger().intValue()) {
indexingHelper.sendDocuments(fessEsClient, docList);
}
executeTime += System.currentTimeMillis() - startTime;
}
documentSize.getAndIncrement();
if (logger.isDebugEnabled()) {
logger.debug("The number of an added document is " + documentSize.get() + ".");
}
}
Aggregations