001/* 002 * (C) Copyright 2006-2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Florent Guillaume 018 * Stephane Lacoin 019 */ 020package org.nuxeo.ecm.core.storage.sql.coremodel; 021 022import org.apache.commons.logging.Log; 023import org.apache.commons.logging.LogFactory; 024import org.nuxeo.ecm.core.storage.DefaultFulltextParser; 025import org.nuxeo.ecm.core.storage.FulltextExtractorWork; 026import org.nuxeo.ecm.core.storage.FulltextParser; 027import org.nuxeo.ecm.core.storage.FulltextUpdaterWork; 028import org.nuxeo.runtime.api.Framework; 029 030/** 031 * Work task that does fulltext extraction from the blobs of the given document. 032 * <p> 033 * The extracted fulltext is then passed to the single-threaded {@link FulltextUpdaterWork}. 034 * 035 * @since 5.7 036 */ 037public class SQLFulltextExtractorWork extends FulltextExtractorWork { 038 039 private static final long serialVersionUID = 1L; 040 041 public SQLFulltextExtractorWork(String repositoryName, String docId) { 042 super(repositoryName, docId, true); 043 } 044 045 private static final Log log = LogFactory.getLog(SQLFulltextExtractorWork.class); 046 047 @Override 048 public void initFulltextConfigurationAndParser() { 049 SQLRepositoryService sqlRepositoryService = Framework.getService(SQLRepositoryService.class); 050 fulltextConfiguration = sqlRepositoryService.getFulltextConfiguration(repositoryName); 051 Class<? extends FulltextParser> fulltextParserClass = sqlRepositoryService.getFulltextParserClass(repositoryName); 052 fulltextParser = new DefaultFulltextParser(); 053 if (fulltextParserClass != null) { 054 try { 055 fulltextParser = fulltextParserClass.newInstance(); 056 } catch (InstantiationException e) { 057 log.error("Failed to instantiate " + fulltextParserClass.getCanonicalName(), e); 058 } catch (IllegalAccessException e) { 059 log.error("Failed to instantiate " + fulltextParserClass.getCanonicalName(), e); 060 } 061 } 062 } 063 064}