use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class LtrQueryRescorer method evaluate.
@Override
public RescorerBuilder<?> evaluate(final Map<String, Object> params) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final String modelName = fessConfig.getLtrModelName();
if (StringUtil.isBlank(modelName)) {
return null;
}
return new QueryRescorerBuilder(new StoredLtrQueryBuilder().modelName(modelName).params(params)).windowSize(fessConfig.getLtrWindowSize());
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class AdminStorageAction method downloadObject.
public static void downloadObject(final String objectName, final WrittenStreamOut out) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final GetObjectArgs args = GetObjectArgs.builder().bucket(fessConfig.getStorageBucket()).object(objectName).build();
try (InputStream in = createClient(fessConfig).getObject(args)) {
out.write(in);
} catch (final Exception e) {
throw new StorageException("Failed to download " + objectName, e);
}
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class AdminStorageAction method getFileItems.
public static List<Map<String, Object>> getFileItems(final String prefix) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final ArrayList<Map<String, Object>> list = new ArrayList<>();
try {
final MinioClient minioClient = createClient(fessConfig);
final ListObjectsArgs args = ListObjectsArgs.builder().bucket(fessConfig.getStorageBucket()).prefix(prefix != null && prefix.length() > 0 ? prefix + "/" : prefix).recursive(false).includeUserMetadata(false).useApiVersion1(false).build();
for (final Result<Item> result : minioClient.listObjects(args)) {
final Map<String, Object> map = new HashMap<>();
final Item item = result.get();
final String objectName = item.objectName();
map.put("id", encodeId(objectName));
map.put("name", getName(objectName));
map.put("hashCode", item.hashCode());
map.put("size", item.size());
map.put("directory", item.isDir());
if (!item.isDir()) {
map.put("lastModified", item.lastModified());
}
list.add(map);
if (list.size() > fessConfig.getStorageMaxItemsInPageAsInteger()) {
break;
}
}
} catch (final ErrorResponseException e) {
final String code = e.errorResponse().code();
if ("NoSuchBucket".equals(code)) {
final MinioClient minioClient = createClient(fessConfig);
try {
final MakeBucketArgs args = MakeBucketArgs.builder().bucket(fessConfig.getStorageBucket()).build();
minioClient.makeBucket(args);
logger.info("Created bucket: {}", fessConfig.getStorageBucket());
} catch (final Exception e1) {
logger.warn("Failed to create bucket: {}", fessConfig.getStorageBucket(), e1);
}
} else if (logger.isDebugEnabled()) {
logger.debug("Failed to access {}", fessConfig.getStorageEndpoint(), e);
}
} catch (final Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to access {}", fessConfig.getStorageEndpoint(), e);
}
}
return list;
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class AdminGeneralAction method sendmail.
@Execute
@Secured({ ROLE })
public HtmlResponse sendmail(final MailForm form) {
validate(form, messages -> {
}, () -> asHtml(path_AdminGeneral_AdminGeneralJsp));
final String[] toAddresses = form.notificationTo.split(",");
final Map<String, Object> dataMap = new HashMap<>();
dataMap.put("hostname", systemHelper.getHostname());
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final Postbox postbox = ComponentUtil.getComponent(Postbox.class);
try {
TestmailPostcard.droppedInto(postbox, postcard -> {
postcard.setFrom(fessConfig.getMailFromAddress(), fessConfig.getMailFromName());
postcard.addReplyTo(fessConfig.getMailReturnPath());
stream(toAddresses).of(stream -> stream.forEach(address -> {
postcard.addTo(address);
}));
BeanUtil.copyMapToBean(dataMap, postcard);
});
saveInfo(messages -> messages.addSuccessSendTestmail(GLOBAL));
updateProperty(Constants.NOTIFICATION_TO_PROPERTY, form.notificationTo);
systemProperties.store();
} catch (final Exception e) {
logger.warn("Failed to send a test mail.", e);
saveError(messages -> messages.addErrorsFailedToSendTestmail(GLOBAL));
}
return redirectByParam(AdminGeneralAction.class, "notificationTo", form.notificationTo);
}
use of org.codelibs.fess.mylasta.direction.FessConfig in project fess by codelibs.
the class CrawlingConfig method initializeDefaultHttpProxy.
default void initializeDefaultHttpProxy(final Map<String, Object> paramMap) {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
final String proxyHost = fessConfig.getHttpProxyHost();
final String proxyPort = fessConfig.getHttpProxyPort();
if (StringUtil.isNotBlank(proxyHost) && StringUtil.isNotBlank(proxyPort)) {
paramMap.put(Param.Client.PROXY_HOST, proxyHost);
paramMap.put(Param.Client.PROXY_PORT, proxyPort);
final String proxyUsername = fessConfig.getHttpProxyUsername();
final String proxyPassword = fessConfig.getHttpProxyPassword();
if (proxyUsername != null && proxyPassword != null) {
paramMap.put(HcHttpClient.PROXY_CREDENTIALS_PROPERTY, new UsernamePasswordCredentials(proxyUsername, proxyPassword));
}
}
}
Aggregations