KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > legacy > CmsPageDocument


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/legacy/CmsPageDocument.java,v $
3  * Date : $Date: 2005/06/27 23:27:46 $
4  * Version: $Revision: 1.8 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

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 /**
46  * Lucene document factory class to extract index data from a cms resource
47  * of type <code>CmsResourceTypePage</code>.<p>
48  *
49  * @version $Revision: 1.8 $ $Date: 2005/06/27 23:27:46 $
50  * @author Carsten Weinholz (c.weinholz@alkacon.com)
51  *
52  * @deprecated Will not be supported past the OpenCms 6 release.
53  */

54 public class CmsPageDocument extends A_CmsVfsDocument {
55
56     /**
57      * Creates a new instance of this lucene document factory.<p>
58      *
59      * @param name name of the documenttype
60      */

61     public CmsPageDocument (String JavaDoc name) {
62         super(name);
63     }
64     
65     /**
66      * Gets the raw text content of a cms resource.<p>
67      *
68      * @see org.opencms.search.documents.A_CmsVfsDocument#extractContent(org.opencms.file.CmsObject, org.opencms.search.A_CmsIndexResource, java.lang.String)
69      */

70     public I_CmsExtractionResult extractContent(CmsObject cms, A_CmsIndexResource indexResource, String JavaDoc language) throws CmsException {
71
72         CmsResource resource = (CmsResource)indexResource.getData();
73         String JavaDoc rawContent = null;
74         
75         try {
76             CmsXmlTemplateFile file = new CmsXmlTemplateFile(cms, cms.getRequestContext().removeSiteRoot(resource.getRootPath()));
77             String JavaDoc content = file.getProcessedTemplateContent(null, null);
78             
79             StringExtractor extractor = new StringExtractor(content);
80             rawContent = extractor.extractStrings(true);
81         } catch (Exception JavaDoc exc) {
82             throw new CmsLegacyException("Reading resource " + resource.getRootPath() + " failed", exc);
83         }
84         
85         return new CmsExtractionResult(rawContent);
86     }
87 }
88
Popular Tags