use of org.codelibs.fess.app.service.FileConfigService 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;
}
}
use of org.codelibs.fess.app.service.FileConfigService 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);
}
Aggregations