1 31 package com.opencms.legacy; 32 33 import org.opencms.file.CmsObject; 34 import org.opencms.file.CmsResource; 35 import org.opencms.main.CmsException; 36 import org.opencms.search.A_CmsIndexResource; 37 import org.opencms.search.documents.A_CmsVfsDocument; 38 import org.opencms.search.extractors.CmsExtractionResult; 39 import org.opencms.search.extractors.I_CmsExtractionResult; 40 41 import com.opencms.template.*; 42 43 import org.htmlparser.parserapplications.StringExtractor; 44 45 54 public class CmsPageDocument extends A_CmsVfsDocument { 55 56 61 public CmsPageDocument (String name) { 62 super(name); 63 } 64 65 70 public I_CmsExtractionResult extractContent(CmsObject cms, A_CmsIndexResource indexResource, String language) throws CmsException { 71 72 CmsResource resource = (CmsResource)indexResource.getData(); 73 String rawContent = null; 74 75 try { 76 CmsXmlTemplateFile file = new CmsXmlTemplateFile(cms, cms.getRequestContext().removeSiteRoot(resource.getRootPath())); 77 String content = file.getProcessedTemplateContent(null, null); 78 79 StringExtractor extractor = new StringExtractor(content); 80 rawContent = extractor.extractStrings(true); 81 } catch (Exception exc) { 82 throw new CmsLegacyException("Reading resource " + resource.getRootPath() + " failed", exc); 83 } 84 85 return new CmsExtractionResult(rawContent); 86 } 87 } 88 | Popular Tags |