KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > search > CmsVfsIndexResource


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/search/CmsVfsIndexResource.java,v $
3  * Date : $Date: 2005/07/28 15:53:10 $
4  * Version: $Revision: 1.20 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (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 GmbH, 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
32 package org.opencms.search;
33
34 import org.opencms.file.CmsResource;
35 import org.opencms.file.types.I_CmsResourceType;
36 import org.opencms.loader.CmsResourceManager;
37 import org.opencms.main.OpenCms;
38 import org.opencms.search.documents.A_CmsVfsDocument;
39
40 /**
41  * Contains the data of a VFS Cms resource specified by a Lucene
42  * search result document.<p>
43  *
44  * @author Carsten Weinholz
45  * @author Thomas Weckert
46  *
47  * @version $Revision: 1.20 $
48  *
49  * @since 6.0.0
50  */

51 public class CmsVfsIndexResource extends A_CmsIndexResource {
52
53     /**
54      * Creates a new instance to wrap the given <code>{@link CmsResource}</code>.<p>
55      *
56      * @param res the data object
57      */

58     public CmsVfsIndexResource(CmsResource res) {
59
60         m_data = res;
61         m_id = res.getStructureId();
62         m_name = res.getName();
63
64         try {
65             I_CmsResourceType resourceType = OpenCms.getResourceManager().getResourceType(res.getTypeId());
66             m_type = resourceType.getTypeId();
67         } catch (Exception JavaDoc exc) {
68             m_type = res.getTypeId();
69         }
70
71         // default to plain text mime type if no matching file extension id found
72
m_mimeType = OpenCms.getResourceManager().getMimeType(res.getName(), null, CmsResourceManager.MIMETYPE_TEXT);
73         m_path = res.getRootPath();
74     }
75
76     /**
77      * @see org.opencms.search.A_CmsIndexResource#getDocumentKey(boolean)
78      */

79     public String JavaDoc getDocumentKey(boolean withMimeType) {
80
81         StringBuffer JavaDoc result = new StringBuffer JavaDoc(32);
82         result.append(A_CmsVfsDocument.VFS_DOCUMENT_KEY_PREFIX);
83         result.append(getType());
84         if (withMimeType) {
85             result.append(":");
86             result.append(getMimetype());
87         }
88         return result.toString();
89     }
90 }
Popular Tags