2 Replies Latest reply on Aug 13, 2009 7:11 AM by tomhombergs

    Search Portlet?

      Hi all,

      is there a Search Portlet available for JBoss Portal? I imagine it should somehow (nightly?) invoke all portal pages and index their contents. The UI should show a search box and display a result list with links to the matching portal pages.

      Searches in Google and JBoss Community produced this question quite often, but no answers (which might be interpreted as a "no", though) :(.

        • 1. Re: Search Portlet?
          albertodominguezs

          Hi Tom,

          I didn't get any help or info. However, while I was debugging a custom LoginModule I found some really useful lines inside the org.jboss.portal.core.cms.ui.admin.CMSAdminPortlet.java.

          Hope these lines work for you.

          package org.jboss.portal.core.cms.ui.admin;
          
          // ...
          
          public class CMSAdminPortlet extends JBossPortlet
          {
          
          // ...
          
          private void internalDoView(JBossRenderRequest rReq, JBossRenderResponse rRes)
           throws CMSException, PortletException, IOException
           {
          
          // ...
          
          else if (CMSAdminConstants.OP_VIEWSEARCHRESULTS.equals(op))
           {
           rRes.setContentType("text/html");
          
           String textQuery = rReq.getParameter("search");
           FederatedQuery query = new FederatedQuery(textQuery);
          
           JCRQueryConverter converter = new JCRQueryConverter();
          
           List files;
           try
           {
           Command searchCommand = CMSService.getCommandFactory().createSearchCommand((JCRQuery)converter.convert(query));
           files = (List)CMSService.execute(searchCommand);
           }
           catch (CMSException e)
           {
           e.printStackTrace();
           files = new ArrayList();
           }
           catch (QueryConversionException e)
           {
           files = new ArrayList();
           rReq.setAttribute("conversionError", Boolean.TRUE);
           }
           rReq.setAttribute("files", files);
           rReq.setAttribute("textQuery", textQuery);
          
           javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(CMSAdminConstants.CMS_JSP_PATH + "/searchResults.jsp");
           prd.include(rReq, rRes);
           }
          



          • 2. Re: Search Portlet?

            Hi Alberto,

            thanks for the reply. I guess the code you posted only searches the jboss-cms content, though.

            However, I now built a custom solution using Apache Lucene as search engine. Sadly, it's not a generic solution but rather specific for our purposes.