Search in sources :

Example 71 with FessConfig

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());
}
Also used : QueryRescorerBuilder(org.opensearch.search.rescore.QueryRescorerBuilder) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StoredLtrQueryBuilder(org.codelibs.fess.es.query.StoredLtrQueryBuilder)

Example 72 with FessConfig

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);
    }
}
Also used : InputStream(java.io.InputStream) GetObjectArgs(io.minio.GetObjectArgs) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StorageException(org.codelibs.fess.exception.StorageException) StorageException(org.codelibs.fess.exception.StorageException) ErrorResponseException(io.minio.errors.ErrorResponseException)

Example 73 with FessConfig

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;
}
Also used : MakeBucketArgs(io.minio.MakeBucketArgs) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) StorageException(org.codelibs.fess.exception.StorageException) ErrorResponseException(io.minio.errors.ErrorResponseException) ListObjectsArgs(io.minio.ListObjectsArgs) Item(io.minio.messages.Item) MinioClient(io.minio.MinioClient) ErrorResponseException(io.minio.errors.ErrorResponseException) HashMap(java.util.HashMap) Map(java.util.Map)

Example 74 with FessConfig

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);
}
Also used : BeanUtil(org.codelibs.core.beans.util.BeanUtil) Constants(org.codelibs.fess.Constants) Secured(org.codelibs.fess.annotation.Secured) StreamUtil.stream(org.codelibs.core.stream.StreamUtil.stream) DynamicProperties(org.codelibs.core.misc.DynamicProperties) Resource(javax.annotation.Resource) StringUtil(org.codelibs.core.lang.StringUtil) HashMap(java.util.HashMap) ActionRuntime(org.lastaflute.web.ruts.process.ActionRuntime) ArrayList(java.util.ArrayList) Postbox(org.lastaflute.core.mail.Postbox) List(java.util.List) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) Logger(org.apache.logging.log4j.Logger) TestmailPostcard(org.codelibs.fess.mylasta.mail.TestmailPostcard) ComponentUtil(org.codelibs.fess.util.ComponentUtil) FessAdminAction(org.codelibs.fess.app.web.base.FessAdminAction) SystemHelper(org.codelibs.fess.helper.SystemHelper) Map(java.util.Map) Execute(org.lastaflute.web.Execute) HtmlResponse(org.lastaflute.web.response.HtmlResponse) LogManager(org.apache.logging.log4j.LogManager) HashMap(java.util.HashMap) Postbox(org.lastaflute.core.mail.Postbox) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) Execute(org.lastaflute.web.Execute) Secured(org.codelibs.fess.annotation.Secured)

Example 75 with FessConfig

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));
        }
    }
}
Also used : FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)176 ArrayList (java.util.ArrayList)60 Map (java.util.Map)54 HashMap (java.util.HashMap)48 StringUtil (org.codelibs.core.lang.StringUtil)42 ComponentUtil (org.codelibs.fess.util.ComponentUtil)42 List (java.util.List)37 Constants (org.codelibs.fess.Constants)36 LogManager (org.apache.logging.log4j.LogManager)30 Logger (org.apache.logging.log4j.Logger)30 StreamUtil.stream (org.codelibs.core.stream.StreamUtil.stream)28 PostConstruct (javax.annotation.PostConstruct)27 IOException (java.io.IOException)24 SystemHelper (org.codelibs.fess.helper.SystemHelper)19 File (java.io.File)18 Collectors (java.util.stream.Collectors)18 SearchEngineClient (org.codelibs.fess.es.client.SearchEngineClient)18 FessSystemException (org.codelibs.fess.exception.FessSystemException)17 Collections (java.util.Collections)15 DocumentUtil (org.codelibs.fess.util.DocumentUtil)15