[opencms-dev] Lucene Search issues with JSPs

Ivan Biddles ivanb at scientology.net
Thu Nov 14 18:34:39 CET 2002


Thanks, Alex, it was looking that way to me so I'm glad you confirmed it
and pointed me in the right direction.

I have worked around the problem by simply changing the code to check
first whether it is really a CmsXmlTemplate and ignoring any files that
are not. 

This works for me because the majority of my pages are static HTML and
the JSPs are only for special (personal) pages that probably don't need
to be in the search anyway.

So, for anyone in the same boat, below is the code snippet for the
C_FILE_HTML case (around line 267 of IndexBackoffice.java.

Best wishes,
            Ivan


        case C_FILE_HTML:

          CmsXmlControlFile controlFile = new CmsXmlControlFile(cms,
path);
          bodyElementClassName =
controlFile.getElementClass(C_BODY_ELEMENT);
          tempObj = CmsTemplateClassManager.getClassInstance(cms,
bodyElementClassName);
          if (tempObj instanceof CmsXmlTemplate) {
             CmsXmlTemplate bodyElementClassObject =
(CmsXmlTemplate)tempObj;
             bodyFilename = C_CONTENTBODYPATH+path.substring(1);
             CmsXmlTemplateFile bodyTemplateFile =
bodyElementClassObject.getOwnTemplateFile(cms, bodyFilename,
C_BODY_ELEMENT, null, null);
             title = cms.readProperty(path,C_PROPERTY_TITLE);
             if(title == null) {title = path;}
             String contents =
HTMLStripper(bodyTemplateFile.getTemplateContent(this, null, null));
             String summary = summary(contents,200);

             docmt = new Document();
             docmt.add(Field.Text("title", title));
             docmt.add(Field.Text("url", path));
             docmt.add(Field.Text("contents", contents));
             docmt.add(Field.Text("summary", summary));
             writer.addDocument(docmt);

             template.setData("item","html: "+path);
             result.append(template.getProcessedDataValue("content"));
          }
          else {
             A_OpenCms.log (C_OPENCMS_INFO, "Ignoring non-HTML-based
file: \"" + path + "\"");
          }
          break;

-----Original Message-----
From: owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Alexander
Kandzior
Sent: Thursday, November 14, 2002 00:15
To: opencms-dev at www.opencms.org
Subject: RE: [opencms-dev] Lucene Search issues with JSPs

Ivan,

the approach taken by the Lucene search engine module is not compatible
with JSPs. The module must be modified to work with JSPs, as JSPs will
never be of type CmsXmlTemplate, obviously. 

Best Regards,
Alex.

Alexander Kandzior
OpenCms Group / Alkacon Software

> -----Original Message-----
> From: owner-opencms-dev at www.opencms.org 
> [mailto:owner-opencms-dev at www.opencms.org] On Behalf Of Ivan Biddles
> Sent: Thursday, November 14, 2002 8:39 AM
> To: opencms-dev at www.opencms.org
> Subject: RE: [opencms-dev] Lucene Search issues with JSPs
> 
> 
> Hi again,
> 
> My problem is definitely to do with JSPs.
> 
> I have found that if I index only folders that do not have 
> JSPs it works fine, but the first page that includes a JSP 
> causes the crash - in
> IndexBackoffice.addContent() at the following line in the 
> C_FILE_HTML case of switch getFileType ():
> 
>       CmsXmlTemplate bodyElementClassObject = (CmsXmlTemplate)tempObj;
> 
> The template in my JSP case is CmsJspTemplate not CmsXmlTemplate.
> 
> So if anyone has an idea here, I'd be very grateful.
> 
> Thanks,
>         Ivan
> 
> -----Original Message-----
> From: owner-opencms-dev at www.opencms.org 
> [mailto:owner-opencms-dev at www.opencms.org] On > Behalf Of Ivan 
> Biddles
> Sent: Wednesday, November 13, 2002 13:49
> To: opencms-dev at www.opencms.org
> Subject: [opencms-dev] Module Management - unable to upload
> 
> Hi,
> 
> I am trying to get the Lucene Search Engine working using the 
> integration module. However when I get to the point where I 
> try to index my content, I get:
> 
>      java.lang.ClassCastException: com.opencms.flex.CmsJspTemplate
> 
> Is this because I have JSPs within my content hierarchy, or 
> could it be because I have templates that include JSPs, or is 
> this a bug?
> 
> If it is a problem caused by the way I have structured 
> things, what would be the recommended places to put my HTML 
> pages, JSPs, CSSs, and templates?
> 
> I assume that I should create a top level folder and put 
> everything under that, but I would like to conform to the standards.
> 
> Particularly is there any way to get the body content under 
> my same directory rather than in /system/bodies? That way I 
> could export everything from that one folder.
> 
> Thanks,
>          Ivan
> 
> (BTW, I am running into the Lucene problem on 5.0 Beta 1, as 
> I haven't had a chance to upgrade to Beta 2 on my main 
> machine as yet. I have Beta 2 up on another machine and the 
> directory structure is very clean - great job on that.)
> 





More information about the opencms-dev mailing list