View Javadoc
1   /*
2    * Copyright 2012-2017 CodeLibs Project and the Others.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.codelibs.fess.crawler.transformer;
17  
18  import javax.annotation.PostConstruct;
19  
20  import org.codelibs.fess.crawler.entity.ResponseData;
21  import org.codelibs.fess.crawler.extractor.Extractor;
22  import org.codelibs.fess.exception.FessSystemException;
23  import org.codelibs.fess.mylasta.direction.FessConfig;
24  import org.codelibs.fess.util.ComponentUtil;
25  import org.slf4j.Logger;
26  import org.slf4j.LoggerFactory;
27  
28  public class FessTikaTransformer extends AbstractFessFileTransformer {
29      private static final Logger logger = LoggerFactory.getLogger(FessTikaTransformer.class);
30  
31      @PostConstruct
32      public void init() {
33          fessConfig = ComponentUtil.getFessConfig();
34      }
35  
36      @Override
37      public FessConfig getFessConfig() {
38          return fessConfig;
39      }
40  
41      @Override
42      public Logger getLogger() {
43          return logger;
44      }
45  
46      @Override
47      protected Extractor getExtractor(final ResponseData responseData) {
48          final Extractor extractor = ComponentUtil.getComponent("tikaExtractor");
49          if (extractor == null) {
50              throw new FessSystemException("Could not find tikaExtractor.");
51          }
52          return extractor;
53      }
54  }