Search in sources :

Example 1 with DataConfigService

use of org.codelibs.fess.app.service.DataConfigService in project fess by codelibs.

the class CrawlingConfigHelper method getCrawlingConfig.

public CrawlingConfig getCrawlingConfig(final String configId) {
    final ConfigType configType = getConfigType(configId);
    if (configType == null) {
        return null;
    }
    final String id = getId(configId);
    if (id == null) {
        return null;
    }
    switch(configType) {
        case WEB:
            final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
            return webConfigService.getWebConfig(id).get();
        case FILE:
            final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
            return fileConfigService.getFileConfig(id).get();
        case DATA:
            final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
            return dataConfigService.getDataConfig(id).get();
        default:
            return null;
    }
}
Also used : DataConfigService(org.codelibs.fess.app.service.DataConfigService) WebConfigService(org.codelibs.fess.app.service.WebConfigService) ConfigType(org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType) FileConfigService(org.codelibs.fess.app.service.FileConfigService)

Example 2 with DataConfigService

use of org.codelibs.fess.app.service.DataConfigService in project fess by codelibs.

the class ViewHelper method asContentResponse.

public StreamResponse asContentResponse(final Map<String, Object> doc) {
    if (logger.isDebugEnabled()) {
        logger.debug("writing the content of: " + doc);
    }
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    final CrawlingConfigHelper crawlingConfigHelper = ComponentUtil.getCrawlingConfigHelper();
    final String configId = DocumentUtil.getValue(doc, fessConfig.getIndexFieldConfigId(), String.class);
    if (configId == null) {
        throw new FessSystemException("configId is null.");
    }
    if (configId.length() < 2) {
        throw new FessSystemException("Invalid configId: " + configId);
    }
    final ConfigType configType = crawlingConfigHelper.getConfigType(configId);
    CrawlingConfig config = null;
    if (logger.isDebugEnabled()) {
        logger.debug("configType: " + configType + ", configId: " + configId);
    }
    if (ConfigType.WEB == configType) {
        final WebConfigService webConfigService = ComponentUtil.getComponent(WebConfigService.class);
        config = webConfigService.getWebConfig(crawlingConfigHelper.getId(configId)).get();
    } else if (ConfigType.FILE == configType) {
        final FileConfigService fileConfigService = ComponentUtil.getComponent(FileConfigService.class);
        config = fileConfigService.getFileConfig(crawlingConfigHelper.getId(configId)).get();
    } else if (ConfigType.DATA == configType) {
        final DataConfigService dataConfigService = ComponentUtil.getComponent(DataConfigService.class);
        config = dataConfigService.getDataConfig(crawlingConfigHelper.getId(configId)).get();
    }
    if (config == null) {
        throw new FessSystemException("No crawlingConfig: " + configId);
    }
    final String url = DocumentUtil.getValue(doc, fessConfig.getIndexFieldUrl(), String.class);
    final CrawlerClientFactory crawlerClientFactory = ComponentUtil.getComponent(CrawlerClientFactory.class);
    config.initializeClientFactory(crawlerClientFactory);
    final CrawlerClient client = crawlerClientFactory.getClient(url);
    if (client == null) {
        throw new FessSystemException("No CrawlerClient: " + configId + ", url: " + url);
    }
    return writeContent(configId, url, client);
}
Also used : DataConfigService(org.codelibs.fess.app.service.DataConfigService) CrawlingConfig(org.codelibs.fess.es.config.exentity.CrawlingConfig) WebConfigService(org.codelibs.fess.app.service.WebConfigService) CrawlerClientFactory(org.codelibs.fess.crawler.client.CrawlerClientFactory) CrawlerClient(org.codelibs.fess.crawler.client.CrawlerClient) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) ConfigType(org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType) FessSystemException(org.codelibs.fess.exception.FessSystemException) FileConfigService(org.codelibs.fess.app.service.FileConfigService)

Aggregations

DataConfigService (org.codelibs.fess.app.service.DataConfigService)2 FileConfigService (org.codelibs.fess.app.service.FileConfigService)2 WebConfigService (org.codelibs.fess.app.service.WebConfigService)2 ConfigType (org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType)2 CrawlerClient (org.codelibs.fess.crawler.client.CrawlerClient)1 CrawlerClientFactory (org.codelibs.fess.crawler.client.CrawlerClientFactory)1 CrawlingConfig (org.codelibs.fess.es.config.exentity.CrawlingConfig)1 FessSystemException (org.codelibs.fess.exception.FessSystemException)1 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)1