Search in sources :

Example 1 with ConfigType

use of org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType in project fess by codelibs.

the class CrawlingConfigHelper method getCrawlingConfig.

public CrawlingConfig getCrawlingConfig(final String configId) {
    try {
        return crawlingConfigCache.get(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;
            }
        });
    } catch (final ExecutionException e) {
        logger.warn("Failed to access a crawling config cache: {}", configId, e);
        return null;
    }
}
Also used : DataConfigService(org.codelibs.fess.app.service.DataConfigService) WebConfigService(org.codelibs.fess.app.service.WebConfigService) ExecutionException(java.util.concurrent.ExecutionException) ConfigType(org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType) FileConfigService(org.codelibs.fess.app.service.FileConfigService)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1 DataConfigService (org.codelibs.fess.app.service.DataConfigService)1 FileConfigService (org.codelibs.fess.app.service.FileConfigService)1 WebConfigService (org.codelibs.fess.app.service.WebConfigService)1 ConfigType (org.codelibs.fess.es.config.exentity.CrawlingConfig.ConfigType)1