001/* 002 * Copyright (c) 2006-2013 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Florent Guillaume 011 * Stephane Lacoin 012 */ 013package org.nuxeo.ecm.core.storage.sql.coremodel; 014 015import org.apache.commons.logging.Log; 016import org.apache.commons.logging.LogFactory; 017import org.nuxeo.ecm.core.storage.DefaultFulltextParser; 018import org.nuxeo.ecm.core.storage.FulltextExtractorWork; 019import org.nuxeo.ecm.core.storage.FulltextParser; 020import org.nuxeo.ecm.core.storage.FulltextUpdaterWork; 021import org.nuxeo.runtime.api.Framework; 022 023/** 024 * Work task that does fulltext extraction from the blobs of the given document. 025 * <p> 026 * The extracted fulltext is then passed to the single-threaded {@link FulltextUpdaterWork}. 027 * 028 * @since 5.7 029 */ 030public class SQLFulltextExtractorWork extends FulltextExtractorWork { 031 032 private static final long serialVersionUID = 1L; 033 034 public SQLFulltextExtractorWork(String repositoryName, String docId) { 035 super(repositoryName, docId, repositoryName + ':' + docId + ":sqlFulltextExtractor", true); 036 } 037 038 private static final Log log = LogFactory.getLog(SQLFulltextExtractorWork.class); 039 040 @Override 041 public void initFulltextConfigurationAndParser() { 042 SQLRepositoryService sqlRepositoryService = Framework.getService(SQLRepositoryService.class); 043 fulltextConfiguration = sqlRepositoryService.getFulltextConfiguration(repositoryName); 044 Class<? extends FulltextParser> fulltextParserClass = sqlRepositoryService.getFulltextParserClass(repositoryName); 045 fulltextParser = new DefaultFulltextParser(); 046 if (fulltextParserClass != null) { 047 try { 048 fulltextParser = fulltextParserClass.newInstance(); 049 } catch (InstantiationException e) { 050 log.error("Failed to instantiate " + fulltextParserClass.getCanonicalName(), e); 051 } catch (IllegalAccessException e) { 052 log.error(e); 053 } 054 } 055 } 056 057}