JBoss Portal SVN: r7888 - trunk/core-cms/src/resources/portal-cms-sar/META-INF.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-08-10 00:54:14 -0400 (Fri, 10 Aug 2007)
New Revision: 7888
Modified:
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1609 - cms cache dependency on cms service is flipped
Modified: trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 04:42:20 UTC (rev 7887)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 04:54:14 UTC (rev 7888)
@@ -57,6 +57,7 @@
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<depends>portal:service=JAASLoginModule</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>cms.pm.cache:service=TreeCache</depends>
<depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">portal:service=Module,type=IdentityServiceController</depends>
<!-- Add this to activate publish/approval workflow integration -->
@@ -263,13 +264,10 @@
<!-- TreeCache configuration used to cache CMS data -->
<mbean code="org.jboss.cache.TreeCache"
- name="cms.pm.cache:service=TreeCache">
-
+ name="cms.pm.cache:service=TreeCache">
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
- <depends>portal:service=CMS</depends>
-
<!--
Configure the TransactionManager
-->
16 years, 9 months
JBoss Portal SVN: r7887 - branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-08-10 00:42:20 -0400 (Fri, 10 Aug 2007)
New Revision: 7887
Modified:
branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
Log:
Fix for JBPORTAL-1146 - java.lang.NegativeArraySizeException in uploading zip archive
Modified: branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-09 15:59:06 UTC (rev 7886)
+++ branches/JBoss_Portal_Branch_2_4/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-10 04:42:20 UTC (rev 7887)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.command;
+import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.impl.ContentImpl;
import org.jboss.portal.cms.impl.FileImpl;
import org.jboss.portal.cms.impl.FolderImpl;
@@ -32,12 +33,16 @@
import org.jboss.portal.cms.util.NodeUtil;
import java.io.InputStream;
+import java.io.FileOutputStream;
+import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
+import java.util.Enumeration;
import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
+import java.util.zip.ZipFile;
+import java.util.StringTokenizer;
/**
* Saves an uploaded archive to the repo.
@@ -52,6 +57,12 @@
InputStream mIS;
String msLanguage;
+ /**
+ *
+ * @param sRootPath
+ * @param is
+ * @param sLanguage
+ */
public StoreArchiveCommand(String sRootPath, InputStream is, String sLanguage)
{
this.msRootPath = sRootPath;
@@ -59,24 +70,36 @@
this.msLanguage = sLanguage;
}
+ /**
+ *
+ */
public Object execute()
{
List contents = new ArrayList();
+ File tmpFile = null;
try
{
- ZipInputStream zis = new ZipInputStream(this.mIS);
- for (ZipEntry zipEntry = zis.getNextEntry(); zipEntry != null; zipEntry = zis.getNextEntry())
+ tmpFile = this.getZipFile();
+
+ ZipFile zipFile = new ZipFile(tmpFile);
+ ZipEntry zipEntry;
+ Enumeration entries = zipFile.entries();
+ while(entries.hasMoreElements())
{
+ zipEntry = (ZipEntry)entries.nextElement();
String itemName = zipEntry.getName();
if (!zipEntry.isDirectory())
- {
- byte[] zipBytes = new byte[(int)zipEntry.getSize()];
- int offset = 0;
- while (offset < zipBytes.length)
+ {
+ long fileSize = zipEntry.getSize();
+ byte[] zipBytes = new byte[(int)fileSize];
+ InputStream zipDataStream = zipFile.getInputStream(zipEntry);
+ long bytesRead = 0;
+
+ while (bytesRead < fileSize)
{
- offset += zis.read(zipBytes, offset, zipBytes.length - offset);
+ bytesRead += zipDataStream.read(zipBytes, (int)bytesRead, (int)(fileSize - bytesRead));
}
-
+
org.jboss.portal.cms.model.File file = new FileImpl();
String sBasePath = FileUtil.cleanDoubleSlashes("/" + this.msRootPath + "/" + itemName);
@@ -97,15 +120,7 @@
Boolean bExists = (Boolean)context.execute(nodeExists);
if (!bExists.booleanValue())
{
- Folder folder = new FolderImpl();
- folder.setName(sParentPath);
- folder.setDescription(sParentPath);
- folder.setTitle(sParentPath);
- folder.setLastModified(new Date());
- folder.setBasePath(sParentPath);
-
- JCRCommand parentSave = (JCRCommand)context.getCommandFactory().createFolderSaveCommand(folder);
- context.execute(parentSave);
+ this.createParentHierarchy(sParentPath);
}
JCRCommand fileSave = (JCRCommand)context.getCommandFactory().createFileSaveCommand(file);
@@ -133,15 +148,7 @@
Boolean bExists = (Boolean)context.execute(nodeExists);
if (!bExists.booleanValue())
{
- Folder folder = new FolderImpl();
- folder.setName(sParentPath);
- folder.setDescription(sParentPath);
- folder.setTitle(sParentPath);
- folder.setLastModified(new Date());
- folder.setBasePath(sParentPath);
-
- JCRCommand parentSave = (JCRCommand)context.getCommandFactory().createFolderSaveCommand(folder);
- context.execute(parentSave);
+ this.createParentHierarchy(sParentPath);
}
JCRCommand nodeExists2 = (JCRCommand)context.getCommandFactory().createItemExistsCommand(sBasePath);
@@ -161,14 +168,93 @@
}
}
}
- zis.close();
return contents;
}
catch (Exception e)
{
e.printStackTrace();
}
+ finally
+ {
+ if(tmpFile != null)
+ {
+ tmpFile.delete();
+ }
+ }
return null;
}
+
+ /**
+ *
+ * @param parentPath
+ */
+ private void createParentHierarchy(String parentPath) throws CMSException
+ {
+ StringTokenizer tokenizer = new StringTokenizer(parentPath,"/");
+
+ StringBuffer buffer = new StringBuffer("/");
+ while(tokenizer.hasMoreTokens())
+ {
+ buffer.append(tokenizer.nextToken());
+ String cour = buffer.toString();
+
+ JCRCommand nodeExists = (JCRCommand)context.getCommandFactory().createItemExistsCommand(cour);
+ Boolean bExists = (Boolean)context.execute(nodeExists);
+ if(!bExists.booleanValue())
+ {
+ this.createFolder(cour);
+ }
+
+ if(tokenizer.hasMoreTokens())
+ {
+ buffer.append("/");
+ }
+ }
+ }
+
+ /**
+ *
+ * @param folderPath
+ * @throws CMSException
+ */
+ private void createFolder(String folderPath) throws CMSException
+ {
+ Folder folder = new FolderImpl();
+ folder.setName(folderPath);
+ folder.setDescription(folderPath);
+ folder.setTitle(folderPath);
+ folder.setLastModified(new Date());
+ folder.setBasePath(folderPath);
+ JCRCommand parentSave = (JCRCommand)context.getCommandFactory().createFolderSaveCommand(folder);
+ context.execute(parentSave);
+ }
+
+ /**
+ *
+ * @return
+ */
+ private File getZipFile() throws Exception
+ {
+ File zipFile = null;
+
+ zipFile = File.createTempFile("jbportal_", "_cmsimport.zip");
+ FileOutputStream fos = new FileOutputStream(zipFile.getCanonicalPath());
+ try
+ {
+ int count;
+ byte[] data = new byte[1024];
+ while ((count = this.mIS.read(data, 0, 1024)) != -1)
+ {
+ fos.write(data, 0, count);
+ fos.flush();
+ }
+ }
+ finally
+ {
+ fos.close();
+ }
+
+ return zipFile;
+ }
}
16 years, 9 months
JBoss Portal SVN: r7886 - branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 11:59:06 -0400 (Thu, 09 Aug 2007)
New Revision: 7886
Modified:
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
- Fix missing dependency
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-09 14:44:54 UTC (rev 7885)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-09 15:59:06 UTC (rev 7886)
@@ -568,5 +568,8 @@
<depends
optional-attribute-name="CommandFactory"
proxy-type="attribute">portal:commandFactory=CMSObject</depends>
+ <depends
+ optional-attribute-name="PortalAuthorizationManagerFactory"
+ proxy-type="attribute">portal:service=PortalAuthorizationManagerFactory</depends>
</mbean>
</server>
16 years, 9 months
JBoss Portal SVN: r7885 - in branches/JBoss_Portal_Branch_2_6/core/src: resources/portal-core-war/WEB-INF/jsp/user and 1 other directory.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 10:44:54 -0400 (Thu, 09 Aug 2007)
New Revision: 7885
Added:
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/user/viewProfile.jsp
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/ui/portlet/user/UserPortlet.java
Log:
- Add "view profile" operation
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/ui/portlet/user/UserPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/ui/portlet/user/UserPortlet.java 2007-08-09 13:15:49 UTC (rev 7884)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/ui/portlet/user/UserPortlet.java 2007-08-09 14:44:54 UTC (rev 7885)
@@ -114,6 +114,9 @@
/** Render operation to show the user profile to edit. */
public static final String OP_SHOWPROFILE = "showProfile";
+ /** Render operation to show a user profile. */
+ public static final String OP_VIEWPROFILE = "viewProfile";
+
/** Render operation to show the screen to assign roles to a user. */
public static final String OP_SHOWADDROLESTOUSER = "showAddRolesToUser";
@@ -230,6 +233,7 @@
return;
}
*/
+
if (req.getRemoteUser() != null)
{
if (req.getWindowState() != WindowState.MAXIMIZED)
@@ -350,6 +354,53 @@
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/editProfile.jsp");
rd.include(req, resp);
}
+ else if (OP_VIEWPROFILE.equals(op))
+ {
+ String userid = req.getParameters().getParameter("userid");
+ User user = null;
+ if (userid != null)
+ {
+ try
+ {
+ user = userModule.findUserById(userid);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot retrieve user", e);
+ }
+ }
+ else
+ {
+ user = req.getUser();
+ try
+ {
+ user = userModule.findUserById(user.getId());
+ }
+ catch (IdentityException e)
+ {
+ log.error("Cannot retrieve user", e);
+ }
+ }
+
+ // Validate we have a user object
+ if (user == null)
+ {
+ throw new PortletException("Not user object found");
+ }
+
+ //
+ DelegateContext ctx = new DelegateContext();
+
+ //
+ ctx.put("username", user.getUserName());
+ fillContextWithUserProfile(user, ctx);
+
+
+ req.setAttribute(PortalJsp.CTX_REQUEST, ctx);
+ resp.setTitle(bundle.getString("REGISTER_PERSONALINFO"));
+ PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/viewProfile.jsp");
+ rd.include(req, resp);
+ }
else if (OP_SHOWMENU.equals(op))
{
DelegateContext ctx = new DelegateContext();
@@ -598,6 +649,52 @@
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/register.jsp");
rd.include(req, resp);
}
+ else if (OP_VIEWPROFILE.equals(op))
+ {
+ String userid = req.getParameters().getParameter("userid");
+ User user = null;
+ if (userid != null)
+ {
+ try
+ {
+ user = userModule.findUserById(userid);
+ }
+ catch (Exception e)
+ {
+ log.error("Cannot retrieve user", e);
+ }
+ }
+ else
+ {
+ user = req.getUser();
+ try
+ {
+ user = userModule.findUserById(user.getId());
+ }
+ catch (IdentityException e)
+ {
+ log.error("Cannot retrieve user", e);
+ }
+ }
+
+ // Validate we have a user object
+ if (user == null)
+ {
+ throw new PortletException("Not user object found");
+ }
+
+ //
+ DelegateContext ctx = new DelegateContext();
+
+ //
+ ctx.put("username", user.getUserName());
+ fillContextWithUserProfile(user, ctx);
+
+
+ req.setAttribute(PortalJsp.CTX_REQUEST, ctx);
+ PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/viewProfile.jsp");
+ rd.include(req, resp);
+ }
else if (OP_SHOWREGISTER_TY.equals(op))
{
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/user/register_ty.jsp");
Added: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/user/viewProfile.jsp
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/user/viewProfile.jsp (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/user/viewProfile.jsp 2007-08-09 14:44:54 UTC (rev 7885)
@@ -0,0 +1,37 @@
+<%@ page language="java" extends="org.jboss.portal.core.servlet.jsp.PortalJsp" %>
+<%@ taglib uri="/WEB-INF/portal-lib.tld" prefix="n" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
+<%@ page isELIgnored="false" %>
+
+<table cellpadding="0" cellspacing="8" border="0" class="pn-normal">
+
+<tr>
+ <td class="portlet-form-label">${n:i18n("LIST_USERNAME")}</td>
+ <td>${n:out("username")}</td>
+</tr>
+<tr>
+ <td class="portlet-form-label">${n:i18n("REGISTER_GIVENNAME")}</td>
+ <td>${n:out("GIVENNAME")}</td>
+</tr>
+<tr>
+ <td class="portlet-form-label">${n:i18n("REGISTER_FAMILYNAME")}</td>
+ <td>${n:out("FAMILYNAME")}</td>
+</tr>
+<tr>
+ <td class="portlet-form-label">${n:i18n("REGISTER_FAKEEMAIL")}</td>
+ <td>${n:out("FAKEEMAIL")}</td>
+</tr>
+<tr>
+ <td class="portlet-form-label">${n:i18n("REGISTER_HOMEPAGE")}</td>
+ <td>${n:out("HOMEPAGE")}</td>
+</tr>
+<tr>
+ <td class="portlet-form-label">${n:i18n("REGISTER_LOCATION")}</td>
+ <td>${n:out("LOCATION")}</td>
+</tr>
+</table>
+
+<form
+ name="<portlet:namespace/>cancel"
+ action="<portlet:renderURL windowState="normal"><portlet:param name="op" value="showMenu"/></portlet:renderURL>"
+ method="post"/>
Property changes on: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-war/WEB-INF/jsp/user/viewProfile.jsp
___________________________________________________________________
Name: svn:executable
+ *
16 years, 9 months
JBoss Portal SVN: r7884 - branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 09:15:49 -0400 (Thu, 09 Aug 2007)
New Revision: 7884
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Term.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java
Removed:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/QueryTerm.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/impl/
Log:
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+import org.jboss.portal.search.Query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class BooleanClause
+{
+ private Query query;
+
+ private boolean isRequired;
+
+ private boolean isProhibited;
+
+ public BooleanClause(Query query, boolean isRequired, boolean isProhibited)
+ {
+ this.query = query;
+ this.isRequired = isRequired;
+ this.isProhibited = isProhibited;
+ }
+
+ public Query getQuery()
+ {
+ return query;
+ }
+
+ public boolean isRequired()
+ {
+ return isRequired;
+ }
+
+ public boolean isProhibited()
+ {
+ return isProhibited;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -0,0 +1,47 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+import java.util.List;
+
+import org.jboss.portal.search.Query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class BooleanQuery implements Query
+{
+ private List clauses;
+
+ public BooleanQuery(List clauses)
+ {
+ this.clauses = clauses;
+ }
+
+ public List getClauses()
+ {
+ return clauses;
+ }
+}
+
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java 2007-08-09 13:07:56 UTC (rev 7883)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -1,137 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-/**
- * The Query object is used to express a query.
- * Common queries use mandatory terms, optional terms and missing terms.
- * For instance you could do a query stating that you absolutely want
- * the keyword 'Mustang' in your query, that the keyword 'car' is optional
- * and could be used to show the results with the two keywords higher
- * in the list and without the keyword 'horse'. In traditional search
- * tools it would be represented as the string: "+mustang car -horse"
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class Query
-{
-
- private List mandatoryTerms;
- private List optionalTerms;
- private List notTerms;
-
- /*
- private List mandatoryQueries;
- private List optionalQueries;
- private List notQueries;
- */
-
- public void addMandatoryTerm(QueryTerm term)
- {
- if (mandatoryTerms == null)
- {
- mandatoryTerms = new ArrayList();
- }
- mandatoryTerms.add(term);
- }
-
- public void addOptionalTerm(QueryTerm term)
- {
- if (optionalTerms == null)
- {
- optionalTerms = new ArrayList();
- }
- optionalTerms.add(term);
- }
-
- public void addNotTerm(QueryTerm term)
- {
- if (notTerms == null)
- {
- notTerms = new ArrayList();
- }
- notTerms.add(term);
- }
-
- /*
- public void addMandatoryQuery(Query query)
- {
- if (mandatoryQueries == null)
- {
- mandatoryQueries = new ArrayList();
- }
- mandatoryQueries.add(query);
- }
-
- public void addOptionalQuery(Query query)
- {
- if (optionalQueries == null)
- {
- optionalQueries = new ArrayList();
- }
- optionalQueries.add(query);
- }
-
- public void addNotQuery(Query query)
- {
- if (notQueries == null)
- {
- notQueries = new ArrayList();
- }
- notQueries.add(query);
- }
-
- public List getMandatoryQueries()
- {
- return mandatoryQueries;
- }
-*/
- public List getMandatoryTerms()
- {
- return mandatoryTerms;
- }
-/*
- public List getNotQueries()
- {
- return notQueries;
- }
-*/
- public List getNotTerms()
- {
- return notTerms;
- }
-/*
- public List getOptionalQueries()
- {
- return optionalQueries;
- }
-*/
- public List getOptionalTerms()
- {
- return optionalTerms;
- }
-}
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/QueryTerm.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/QueryTerm.java 2007-08-09 13:07:56 UTC (rev 7883)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/QueryTerm.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -1,32 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.query;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public interface QueryTerm
-{
-
-}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Term.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Term.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Term.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class Term
+{
+
+ private String field;
+
+ private String text;
+
+ public Term(String field, String text)
+ {
+ setField(field);
+ setText(text);
+ }
+
+ public String getField()
+ {
+ return field;
+ }
+
+ public void setField(String field)
+ {
+ this.field = field;
+ }
+
+ public String getText()
+ {
+ return text;
+ }
+
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java 2007-08-09 13:15:49 UTC (rev 7884)
@@ -0,0 +1,51 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.query;
+
+import org.jboss.portal.search.Query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class TermQuery implements Query
+{
+ private Term term;
+
+ public TermQuery(Term term)
+ {
+ setTerm(term);
+ }
+
+ public Term getTerm()
+ {
+ return term;
+ }
+
+ public void setTerm(Term term)
+ {
+ this.term = term;
+ }
+
+}
+
16 years, 9 months
JBoss Portal SVN: r7883 - branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 09:07:56 -0400 (Thu, 09 Aug 2007)
New Revision: 7883
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java
Log:
- Adding missing files
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQuery.java 2007-08-09 13:07:56 UTC (rev 7883)
@@ -0,0 +1,50 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl.jcr;
+
+import org.jboss.portal.search.Query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JCRQuery implements Query
+{
+ private String jcrQuery;
+
+ public JCRQuery(String jcrQuery)
+ {
+ this.jcrQuery = jcrQuery;
+ }
+
+ public String getJcrQuery()
+ {
+ return jcrQuery;
+ }
+
+ public String toString()
+ {
+ return jcrQuery;
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java 2007-08-09 13:07:56 UTC (rev 7883)
@@ -0,0 +1,99 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl.jcr;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.impl.AbstractQueryConverter;
+import org.jboss.portal.search.query.BooleanClause;
+import org.jboss.portal.search.query.BooleanQuery;
+import org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JCRQueryConverter extends AbstractQueryConverter
+{
+
+ public Query convert(Query query)
+ {
+ if (query == null)
+ {
+ return null;
+ }
+ StringBuffer result = new StringBuffer();
+ result.append("//*[");
+ try
+ {
+ result.append(((JCRQuery)super.convert(query)).getJcrQuery());
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ result.append("]");
+ return new JCRQuery(result.toString());
+ }
+
+ public Query convertTermQuery(TermQuery query)
+ {
+
+ StringBuffer result = new StringBuffer();
+
+ Term term = query.getTerm();
+ result.append("jcr:contains(., '" + term.getText() + "')");
+
+ return new JCRQuery(result.toString());
+ }
+
+ public Query convertBooleanQuery(BooleanQuery query) throws QueryConversionException
+ {
+ List clauses = query.getClauses();
+
+ StringBuffer result = new StringBuffer();
+
+ Iterator it = clauses.iterator();
+ boolean first = true;
+ while (it.hasNext())
+ {
+ BooleanClause clause = (BooleanClause)it.next();
+ if (!first)
+ {
+ result.append(", ");
+ }
+ if (!clause.isProhibited())
+ {
+ result.append(((JCRQuery)super.convert(clause.getQuery())).getJcrQuery());
+ first = false;
+ }
+ }
+ return new JCRQuery(result.toString());
+ }
+
+
+}
16 years, 9 months
JBoss Portal SVN: r7882 - in branches/JBoss_Portal_Branch_2_6/search: .settings and 11 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 08:50:21 -0400 (Thu, 09 Aug 2007)
New Revision: 7882
Added:
branches/JBoss_Portal_Branch_2_6/search/.settings/
branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
Removed:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/jcr/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
Modified:
branches/JBoss_Portal_Branch_2_6/search/.classpath
branches/JBoss_Portal_Branch_2_6/search/build.xml
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
Log:
- Refactored search service
- Started JSF Search portlet
(Increasing my ohloh ranking ;) )
Modified: branches/JBoss_Portal_Branch_2_6/search/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/.classpath 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/.classpath 2007-08-09 12:50:21 UTC (rev 7882)
@@ -3,12 +3,13 @@
<classpathentry kind="src" path="src/main"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3.8.1"/>
- <classpathentry combineaccessrules="false" kind="src" path="/jems"/>
<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<classpathentry kind="lib" path="/thirdparty/jcr/lib/jcr-1.0.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/common"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jems"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/.settings/org.eclipse.jdt.core.prefs 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,12 @@
+#Tue Jul 31 15:51:48 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
Modified: branches/JBoss_Portal_Branch_2_6/search/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/build.xml 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/build.xml 2007-08-09 12:50:21 UTC (rev 7882)
@@ -74,7 +74,10 @@
<!-- Configure modules -->
<call target="configure-modules"/>
<path id="dependentmodule.classpath">
+ <path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
+ <path refid="jboss.portal-identity.classpath"/>
+ <path refid="jboss.portlet-api.classpath"/>
</path>
<!--+=======================================+-->
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface FederatedIndexer
+{
+ /**
+ * Get the ID for this federated search
+ * @return String representing this particular federated search
+ */
+ public String getId();
+
+ /**
+ * Get a localized name for this federated search
+ * @return String
+ */
+ public LocalizedString getDisplayName();
+
+ /**
+ * Method called when this federated search is not used anymore.
+ * This could be the place to destroy any index
+ * @throws IndexingException
+ */
+ public void destroyIndex() throws IndexingException;
+
+ /**
+ * The create method should index the required components
+ * @throws IndexingException
+ */
+ public void createIndex() throws IndexingException;
+
+ /**
+ * Info should return information on the current status
+ * if the federated search
+ * @return
+ */
+ public Info getInfo();
+
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,76 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.identity.config.metadata.profile.LocalizedStringMetaData;
+import org.jboss.portal.search.result.ResultSet;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface FederatedSearcher
+{
+
+ /**
+ * Get the ID for this federated search
+ * @return String representing this particular federated search
+ */
+ public String getId();
+
+ /**
+ * Get a localized name for this federated search
+ * @return String
+ */
+ public LocalizedString getDisplayName();
+
+ /**
+ * From the query object this method is responsible to return the
+ * results of the query
+ * @param query
+ * @return
+ * @throws SearchingException
+ */
+ public ResultSet search(Query query) throws SearchingException;
+
+ /**
+ * TODO: Subject to change...
+ * get the markup fragment for this federated search. A markup level is used
+ * to define different amount of information to provide.
+ * @param results
+ * @param markupLevel
+ * @return
+ */
+ /*
+ public String getMarkup(ResultSet results, int markupLevel);
+
+ public interface MarkupLevel
+ {
+ public static final int FULL = 0;
+ public static final int REDUCED = 1;
+ }
+ */
+}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/IndexingException.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -28,9 +28,7 @@
*/
public class IndexingException extends Exception
{
- /**
- *
- */
+ /** . */
private static final long serialVersionUID = -4153594211827182795L;
public IndexingException(Throwable e)
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/Query.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/Query.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+
+
+/**
+ * The Query object is used to express a query.
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface Query
+{
+
+}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConversionException.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class QueryConversionException extends Exception
+{
+ /** . */
+ private static final long serialVersionUID = -4153594211827182795L;
+
+ public QueryConversionException(Throwable e)
+ {
+ super(e);
+ }
+
+ public QueryConversionException(String msg, Throwable e)
+ {
+ super(msg, e);
+ }
+
+ public QueryConversionException(String msg)
+ {
+ super(msg);
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -22,27 +22,15 @@
******************************************************************************/
package org.jboss.portal.search;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class QueryConverter
+public interface QueryConverter
{
- // TODO: implemement this with something more sofisticated using JavaCC
- // and a simple grammar probably
- /**
- * Convert a string into a Query object
- * @return Query object for the text string
- */
- public static Query convert(String textQuery)
- {
- Query query = new Query();
- query.addOptionalTerm(new KeywordQueryTerm(textQuery));
-
- return query;
- }
+ public Query convert(Query query) throws QueryConversionException;
+
}
+
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,93 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search;
-
-import java.util.Locale;
-
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.ResultSet;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public interface SearchFederated
-{
-
- /**
- * Get the ID for this federated search
- * @return String representing this particular federated search
- */
- public String getId();
-
- /**
- * Get a localized name for this federated search
- * @return String
- */
- public String getName(Locale locale);
-
- /**
- * Method called when this federated search is not used anymore.
- * This could be the place to destry any index
- * @throws IndexingException
- */
- public void destroy() throws IndexingException;
-
- /**
- * The create method should index the required components
- * @throws IndexingException
- */
- public void create() throws IndexingException;
-
- /**
- * Info should return information on the current status
- * if the federated search
- * @return
- */
- public Info getInfo();
-
- /**
- * From the query object this method is responsible to return the
- * results of the query
- * @param query
- * @return
- */
- public ResultSet search(Query query);
-
- /**
- * TODO: Subject to change...
- * get the markup fragment for this federated search. A markup level is used
- * to define different amount of information to provide.
- * @param results
- * @param markupLevel
- * @return
- */
- public String getMarkup(ResultSet results, int markupLevel);
-
- public interface MarkupLevel
- {
- public static final int FULL = 0;
- public static final int REDUCED = 1;
- }
-}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SearchingException.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchingException extends Exception
+{
+ public SearchingException(Throwable e)
+ {
+ super(e);
+ }
+
+ public SearchingException(String msg, Throwable e)
+ {
+ super(msg, e);
+ }
+
+ public SearchingException(String msg)
+ {
+ super(msg);
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/IndexFederation.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,45 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.federation;
+
+import java.util.List;
+
+import org.jboss.portal.search.FederatedIndexer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface IndexFederation
+{
+ public void register(FederatedIndexer federatedIndexer);
+
+ public void unregister(String id);
+
+ public void reindexAll();
+
+ public List getFederatedIndexerList();
+
+ public FederatedIndexer getFederatedIndexer(String id);
+
+}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -24,8 +24,9 @@
import java.util.List;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.SearchingException;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -33,16 +34,16 @@
*/
public interface SearchFederation
{
- public void register(SearchFederated searchFederated);
+ public void register(FederatedSearcher FederatedSearcher);
public void unregister(String id);
- public void reindexAll();
-
- public List getSearchFederatedList();
+ public List getFederatedSearcherList();
- public SearchFederated getSearchFederated(String id);
+ public FederatedSearcher getFederatedSearcher(String id);
- public List search(Query query);
+ public List search(Query query) throws SearchingException;
+ public List search(Query query, List searchers) throws SearchingException;
+
}
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/IndexFederationService.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.federation.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.IndexFederation;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class IndexFederationService extends AbstractJBossService implements IndexFederation
+{
+
+ private Map registry;
+
+ public IndexFederationService()
+ {
+ registry = new HashMap();
+ }
+
+ public synchronized void register(FederatedIndexer federatedIndexer)
+ {
+ if (federatedIndexer == null)
+ {
+ throw new IllegalArgumentException("No null indexer");
+ }
+ String id = federatedIndexer.getId();
+ if (registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting dual registration of " + id);
+ }
+ Map copy = new HashMap(registry);
+ copy.put(id, federatedIndexer);
+ registry = copy;
+ }
+
+ public synchronized void unregister(String id)
+ {
+ if (id == null)
+ {
+ throw new IllegalArgumentException("No null id accepted");
+ }
+ if (!registry.containsKey(id))
+ {
+ throw new IllegalArgumentException("Attempting to unregister unknown federated search service " + id);
+ }
+ Map copy = new HashMap(registry);
+ copy.remove(id);
+ registry = copy;
+ }
+
+ public void reindexAll()
+ {
+ if (registry != null)
+ {
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedIndexer federated = (FederatedIndexer) it.next();
+ int status = federated.getInfo().getStatus();
+ if (status != Info.Status.INDEXING)
+ {
+ Thread thread = new ReindexFederatedIndexThread(federated);
+ thread.run();
+ }
+ }
+ }
+ }
+
+ private class ReindexFederatedIndexThread extends Thread
+ {
+ private FederatedIndexer federated;
+
+ public ReindexFederatedIndexThread(FederatedIndexer federated)
+ {
+ this.federated = federated;
+ }
+
+ public void run()
+ {
+ federated.getInfo().setStatus(Info.Status.INDEXING);
+ try
+ {
+ federated.destroyIndex();
+ federated.createIndex();
+ federated.getInfo().setStatus(Info.Status.AVAILABLE);
+ }
+ catch (IndexingException e)
+ {
+ federated.getInfo().setStatus(Info.Status.CORRUPTED);
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public List getFederatedIndexerList()
+ {
+ return Collections.unmodifiableList(new ArrayList(registry.values()));
+ }
+
+ public FederatedIndexer getFederatedIndexer(String id)
+ {
+ return (FederatedIndexer)registry.get(id);
+ }
+/*
+ public List search(Query query)
+ {
+ List results = new ArrayList();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedIndexer federated = (FederatedIndexer)it.next();
+ if (federated.getInfo().getStatus() == Info.Status.AVAILABLE)
+ {
+ results.add(federated.search(query));
+ }
+ }
+ return results;
+ }
+ */
+}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -30,12 +30,10 @@
import java.util.Map;
import org.jboss.portal.jems.as.system.AbstractJBossService;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.federation.SearchFederation;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.ResultSet;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -51,19 +49,19 @@
registry = new HashMap();
}
- public synchronized void register(SearchFederated searchFederated)
+ public synchronized void register(FederatedSearcher federatedSearcher)
{
- if (searchFederated == null)
+ if (federatedSearcher == null)
{
throw new IllegalArgumentException("No null invoker");
}
- String id = searchFederated.getId();
+ String id = federatedSearcher.getId();
if (registry.containsKey(id))
{
throw new IllegalArgumentException("Attempting dual registration of " + id);
}
Map copy = new HashMap(registry);
- copy.put(id, searchFederated);
+ copy.put(id, federatedSearcher);
registry = copy;
}
@@ -82,71 +80,41 @@
registry = copy;
}
- public void reindexAll()
+ public List getFederatedSearcherList()
{
- if (registry != null)
- {
- Iterator it = registry.values().iterator();
- while (it.hasNext())
- {
- SearchFederated federated = (SearchFederated) it.next();
- int status = federated.getInfo().getStatus();
- if (status != Info.Status.INDEXING)
- {
- Thread thread = new ReindexFederatedThread(federated);
- thread.run();
- }
- }
- }
+ return Collections.unmodifiableList(new ArrayList(registry.values()));
}
-
- private class ReindexFederatedThread extends Thread
- {
- private SearchFederated federated;
-
- public ReindexFederatedThread(SearchFederated federated)
- {
- this.federated = federated;
- }
-
- public void run()
- {
- federated.getInfo().setStatus(Info.Status.INDEXING);
- try
- {
- federated.destroy();
- federated.create();
- federated.getInfo().setStatus(Info.Status.AVAILABLE);
- }
- catch (IndexingException e)
- {
- federated.getInfo().setStatus(Info.Status.CORRUPTED);
- e.printStackTrace();
- }
- }
- }
- public List getSearchFederatedList()
+ public FederatedSearcher getFederatedSearcher(String id)
{
- return Collections.unmodifiableList(new ArrayList(registry.values()));
+ return (FederatedSearcher)registry.get(id);
}
- public SearchFederated getSearchFederated(String id)
+ public List search(Query query) throws SearchingException
{
- return (SearchFederated)registry.get(id);
+ List results = new ArrayList();
+ Iterator it = registry.values().iterator();
+ while (it.hasNext())
+ {
+ FederatedSearcher federated = (FederatedSearcher)it.next();
+ results.add(federated.search(query));
+ }
+ return results;
}
- public List search(Query query)
+ public List search(Query query, List searchers) throws SearchingException
{
List results = new ArrayList();
- Iterator it = registry.values().iterator();
+ Iterator it = searchers.iterator();
while (it.hasNext())
{
- SearchFederated federated = (SearchFederated)it.next();
- if (federated.getInfo().getStatus() == Info.Status.AVAILABLE)
+ String federatedId = (String)it.next();
+ FederatedSearcher federated = getFederatedSearcher(federatedId);
+ if (federated == null)
{
- results.add(federated.search(query));
+ throw new SearchingException("Cannot find searcher: " + federatedId);
}
+ results.add(federated.search(query));
}
return results;
}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,150 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.identity;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.NoSuchUserException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.SearchingException;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.StandardQueryConverter;
+import org.jboss.portal.search.query.BooleanClause;
+import org.jboss.portal.search.query.BooleanQuery;
+import org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
+import org.jboss.portal.search.result.ResultSet;
+import org.jboss.portal.search.result.ResultURL;
+import org.jboss.portal.search.result.impl.PortletResultURL;
+import org.jboss.portal.search.result.impl.SimpleResult;
+import org.jboss.portal.search.result.impl.SimpleResultURL;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UserSearcher extends AbstractFederatedSearcher
+{
+
+ private UserModule userModule;
+
+ public UserSearcher()
+ {
+ setId("user_searcher");
+ setDisplayName(new LocalizedString("User Searcher"));
+ try
+ {
+ userModule = (UserModule) new InitialContext().lookup("java:/portal/UserModule");
+ }
+ catch (NamingException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ }
+
+
+ public ResultSet search(Query query) throws SearchingException
+ {
+ ResultSet resultSet = new ResultSet(this);
+ StandardQueryConverter queryConverter = new StandardQueryConverter();
+
+ try
+ {
+ search(queryConverter.convert(query), resultSet);
+ }
+ catch (QueryConversionException e)
+ {
+ throw new SearchingException("An error occured while searching", e);
+ }
+ return resultSet;
+ }
+
+ private void search(Query query, ResultSet resultSet)
+ {
+ if (query instanceof TermQuery)
+ {
+ searchTerm(((TermQuery)query).getTerm(), resultSet);
+ }
+ else if (query instanceof BooleanQuery)
+ {
+ BooleanQuery booleanQuery = (BooleanQuery)query;
+ Iterator it = booleanQuery.getClauses().iterator();
+ while (it.hasNext())
+ {
+ BooleanClause clause = (BooleanClause)it.next();
+ if (!clause.isProhibited())
+ {
+ search(booleanQuery, resultSet);
+ }
+ }
+ }
+ }
+
+ private void searchTerm(Term term, ResultSet resultSet)
+ {
+ try
+ {
+ User user = userModule.findUserByUserName(term.getText());
+ SimpleResult result = new SimpleResult(getId(), user);
+ result.setTitle(new LocalizedString(user.getUserName()));
+ result.setType(new LocalizedString("User"));
+ Map renderParameters = new HashMap();
+ renderParameters.put("userid", user.getId().toString());
+ renderParameters.put("op", "viewProfile");
+ ResultURL url = new PortletResultURL("default.default.UserPortletWindow", renderParameters);
+ result.setURL(url);
+ resultSet.add(result);
+ }
+ catch (IllegalArgumentException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ catch (NoSuchUserException e)
+ {
+ // Ignore
+ }
+ catch (IdentityException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+ }
+
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.federation.Info;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractFederatedIndexer extends AbstractJBossService implements FederatedIndexer
+{
+
+ private String id;
+
+ private LocalizedString displayName;
+
+ private Info info;
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public void setInfo(Info info)
+ {
+ this.info = info;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,64 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SearchingException;
+import org.jboss.portal.search.result.ResultSet;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractFederatedSearcher extends AbstractJBossService implements FederatedSearcher
+{
+
+ private String id;
+
+ private LocalizedString displayName;
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return displayName;
+ }
+
+ public void setDisplayName(LocalizedString displayName)
+ {
+ this.displayName = displayName;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.QueryConverter;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
+import org.jboss.portal.search.query.BooleanQuery;
+import org.jboss.portal.search.query.TermQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class AbstractQueryConverter implements QueryConverter
+{
+
+ public Query convert(Query query) throws QueryConversionException
+ {
+ if (query instanceof TermQuery)
+ {
+ return convertTermQuery((TermQuery)query);
+ }
+ else if (query instanceof BooleanQuery)
+ {
+ return convertBooleanQuery((BooleanQuery)query);
+ }
+ else if (query instanceof QueryImpl)
+ {
+ StandardQueryConverter converter = new StandardQueryConverter();
+ return convert(converter.convert(query));
+ }
+ else
+ {
+ throw new QueryConversionException("Unknown query type: " + query);
+ }
+ }
+
+ public abstract Query convertTermQuery(TermQuery query);
+
+ public abstract Query convertBooleanQuery(BooleanQuery query) throws QueryConversionException;
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/GenericSearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -24,16 +24,17 @@
import java.util.Locale;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.FederatedSearcher;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class GenericSearchFederated implements SearchFederated
+public abstract class GenericSearchFederated implements FederatedSearcher
{
- public String getName(Locale locale)
+ public LocalizedString getDisplayName(Locale locale)
{
- return getId();
+ return new LocalizedString(getId());
}
}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl;
+
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class QueryImpl extends LuceneQuery
+{
+
+ public QueryImpl(String queryString)
+ {
+ super(queryString);
+ }
+
+}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.QueryConverter;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
+import org.jboss.portal.search.query.BooleanClause;
+import org.jboss.portal.search.query.BooleanQuery;
+import org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class StandardQueryConverter implements QueryConverter
+{
+
+ public Query convert(Query query) throws QueryConversionException
+ {
+ org.apache.lucene.search.Query luceneQuery = ((LuceneQuery) query).getLuceneQuery();
+ return convertFromLucene(luceneQuery);
+ }
+
+ public Query convertFromLucene(org.apache.lucene.search.Query luceneQuery) throws QueryConversionException
+ {
+ if (luceneQuery == null)
+ {
+ return null;
+ }
+ else if (luceneQuery instanceof org.apache.lucene.search.TermQuery)
+ {
+ return convertTermQuery((org.apache.lucene.search.TermQuery)luceneQuery);
+ }
+ else if (luceneQuery instanceof org.apache.lucene.search.BooleanQuery)
+ {
+ return convertBooleanQuery((org.apache.lucene.search.BooleanQuery)luceneQuery);
+ }
+ else
+ {
+ throw new QueryConversionException("Unknown query type: " + luceneQuery.getClass());
+ }
+ }
+
+ public Query convertTermQuery(org.apache.lucene.search.TermQuery luceneQuery)
+ {
+ org.apache.lucene.index.Term term = ((org.apache.lucene.search.TermQuery)luceneQuery).getTerm();
+ return new TermQuery(new Term(term.field(), term.text()));
+ }
+
+ public Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery luceneQuery)
+ {
+ org.apache.lucene.search.BooleanQuery luceneBooleanQuery = (org.apache.lucene.search.BooleanQuery)luceneQuery;
+ org.apache.lucene.search.BooleanClause[] luceneClauses = luceneBooleanQuery.getClauses();
+ List clauses = new ArrayList();
+ for (int i=0; i<luceneClauses.length; i++)
+ {
+ org.apache.lucene.search.BooleanClause luceneClause = luceneClauses[i];
+ try
+ {
+ clauses.add(new BooleanClause(convertFromLucene(luceneClause.query), luceneClause.required, luceneClause.prohibited));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return new BooleanQuery(clauses);
+ }
+}
+
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene)
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/GenericDocument.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,73 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.lucene;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class GenericDocument
-{
- private String title;
-
- private long date;
-
- private Map fields;
-
- public Map getFields()
- {
- return fields;
- }
-
- public long getDate()
- {
- return date;
- }
-
- public void setDate(long date)
- {
- this.date = date;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- public void addField(String name, String value)
- {
- if (fields == null)
- {
- fields = new HashMap();
- }
- fields.put(name, value);
- }
-}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/HibernateSearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,14 @@
+package org.jboss.portal.search.impl.hibernate;
+
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.result.ResultSet;
+
+public class HibernateSearchFederated extends AbstractFederatedSearcher {
+
+ public ResultSet search(Query query) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneQueryConverter.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,106 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.lucene;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.QueryTerm;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.DateTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryConverter
-{
-
- public static String convert(Query query)
- {
- StringBuffer result = new StringBuffer();
- Iterator it;
-
- List terms = query.getMandatoryTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "+");
- }
- }
-
- terms = query.getNotTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "-");
- }
- }
-
- terms = query.getOptionalTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "");
- }
- }
- return result.toString();
- }
-
- private static void convert(StringBuffer result, QueryTerm term, String prefix)
- {
- if (term instanceof FieldQueryTerm)
- {
- FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getName() + ":\"" + convertedTerm.getValue()+"\"");
- }
- else if (term instanceof KeywordQueryTerm)
- {
- KeywordQueryTerm convertedTerm = (KeywordQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getKeyWord());
- }
- else if (term instanceof BetweenDatesTerm)
- {
- BetweenDatesTerm convertedTerm = (BetweenDatesTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getFromTime() + "," + convertedTerm.getToTime() + "]");
- }
- else if (term instanceof DateTerm)
- {
- DateTerm convertedTerm = (DateTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getTime() + "," + (convertedTerm.getTime() + 24*60*60*1000) + "}");
- }
- }
-
-}
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/hibernate/LuceneSearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,183 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.lucene;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.lucene.analysis.standard.StandardAnalyzer;
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Searcher;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.ResultSet;
-import org.jboss.portal.search.result.impl.AbstractResult;
-import org.jboss.portal.search.result.impl.SimpleResult;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public abstract class LuceneSearchFederated implements SearchFederated
-{
-
- private IndexWriter index;
-
- private String id;
-
- private Info info;
-
- private String indexPath;
-
- private String defaultField;
-
- public LuceneSearchFederated(String id, String indexPath, String defaultField)
- {
- this.id = id;
- this.indexPath = indexPath;
- this.defaultField = defaultField;
- info = new Info();
- }
-
- public void create() throws IndexingException
- {
-
- try
- {
- index = new IndexWriter(indexPath, new StandardAnalyzer(), true);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- info.setStatus(Info.Status.INDEXING);
- try
- {
- List documents = getLuceneDocuments();
- Iterator it = documents.iterator();
- while (it.hasNext())
- {
- Document document = (Document)it.next();
- index.addDocument(document);
- }
- index.optimize();
- index.close();
- }
- catch (IOException e)
- {
- throw new IndexingException("Cannot index document", e);
- }
- info.setStatus(Info.Status.STARTED);
- }
-
- public List getLuceneDocuments()
- {
- List documents = getDocuments();
- Iterator it = documents.iterator();
- while (it.hasNext())
- {
- GenericDocument genericDoc = (GenericDocument) it.next();
- Document doc = new Document();
- if (genericDoc.getTitle() != null)
- doc.add(Field.Text("title", genericDoc.getTitle()));
- if (genericDoc.getDate() != 0)
- doc.add(Field.Text("date", genericDoc.getDate()+""));
- if (genericDoc.getFields() != null)
- {
- Map map = genericDoc.getFields();
- Iterator itKeys = map.keySet().iterator();
- while (itKeys.hasNext())
- {
- String key = (String)itKeys.next();
- doc.add(Field.Text(key, (String)map.get(key)));
- }
- }
- documents.add(doc);
- }
- return documents;
- }
-
- public abstract List getDocuments();
-
- public void destroy()
- {
- info.setStatus(Info.Status.STOPPED);
- }
-
- public String getId()
- {
- return id;
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public ResultSet search(Query query)
- {
- ResultSet result = new ResultSet(this);
- String luceneQueryString = LuceneQueryConverter.convert(query);
- QueryParser parser = new QueryParser(defaultField, new StandardAnalyzer());
- try
- {
- org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
- Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(luceneQuery);
- for (int i=0; i<hits.length(); i++)
- {
- result.add(new SimpleResult(id, hits.doc(i)));
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- return result;
- }
-
- public String getMarkup(ResultSet results, int markupLevel)
- {
- StringBuffer buffer = new StringBuffer();
- Iterator it = results.iterator();
- while (it.hasNext())
- {
- AbstractResult result = (AbstractResult) it.next();
- Document document = (Document)((SimpleResult)result).getValue();
- buffer.append("Id:" + document.getField("id").stringValue());
- buffer.append(" ");
- }
- return buffer.toString();
- }
-
-}
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene)
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/GenericDocument.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,73 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.lucene;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class GenericDocument
-{
- private String title;
-
- private long date;
-
- private Map fields;
-
- public Map getFields()
- {
- return fields;
- }
-
- public long getDate()
- {
- return date;
- }
-
- public void setDate(long date)
- {
- this.date = date;
- }
-
- public String getTitle()
- {
- return title;
- }
-
- public void setTitle(String title)
- {
- this.title = title;
- }
-
- public void addField(String name, String value)
- {
- if (fields == null)
- {
- fields = new HashMap();
- }
- fields.put(name, value);
- }
-}
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federated/lucene/GenericDocument.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/GenericDocument.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,73 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl.lucene;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class GenericDocument
+{
+ private String title;
+
+ private long date;
+
+ private Map fields;
+
+ public Map getFields()
+ {
+ return fields;
+ }
+
+ public long getDate()
+ {
+ return date;
+ }
+
+ public void setDate(long date)
+ {
+ this.date = date;
+ }
+
+ public String getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle(String title)
+ {
+ this.title = title;
+ }
+
+ public void addField(String name, String value)
+ {
+ if (fields == null)
+ {
+ fields = new HashMap();
+ }
+ fields.put(name, value);
+ }
+}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.impl.lucene;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.jboss.logging.Logger;
+import org.jboss.portal.search.Query;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQuery implements Query
+{
+ private org.apache.lucene.search.Query query;
+
+ private Logger logger = Logger.getLogger(LuceneQuery.class);
+
+ public LuceneQuery(String queryString)
+ {
+ try
+ {
+ query = QueryParser.parse(queryString, "all" , new StandardAnalyzer());
+ }
+ catch (ParseException e)
+ {
+ logger.debug("Cannot parse query: " + queryString);
+ }
+ }
+
+ public LuceneQuery(org.apache.lucene.search.Query query)
+ {
+ this.query = query;
+ }
+
+ public org.apache.lucene.search.Query getLuceneQuery()
+ {
+ return query;
+ }
+}
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneQueryConverter.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,106 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.lucene;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.QueryTerm;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.DateTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryConverter
-{
-
- public static String convert(Query query)
- {
- StringBuffer result = new StringBuffer();
- Iterator it;
-
- List terms = query.getMandatoryTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "+");
- }
- }
-
- terms = query.getNotTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "-");
- }
- }
-
- terms = query.getOptionalTerms();
- if (terms != null)
- {
- it = terms.iterator();
- while (it.hasNext())
- {
- QueryTerm term = (QueryTerm) it.next();
- convert(result, term, "");
- }
- }
- return result.toString();
- }
-
- private static void convert(StringBuffer result, QueryTerm term, String prefix)
- {
- if (term instanceof FieldQueryTerm)
- {
- FieldQueryTerm convertedTerm = (FieldQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getName() + ":\"" + convertedTerm.getValue()+"\"");
- }
- else if (term instanceof KeywordQueryTerm)
- {
- KeywordQueryTerm convertedTerm = (KeywordQueryTerm) term;
- result.append(" " + prefix + convertedTerm.getKeyWord());
- }
- else if (term instanceof BetweenDatesTerm)
- {
- BetweenDatesTerm convertedTerm = (BetweenDatesTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getFromTime() + "," + convertedTerm.getToTime() + "]");
- }
- else if (term instanceof DateTerm)
- {
- DateTerm convertedTerm = (DateTerm) term;
- result.append(" " + prefix + convertedTerm.getField() + ":[" + convertedTerm.getTime() + "," + (convertedTerm.getTime() + 24*60*60*1000) + "}");
- }
- }
-
-}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/lucene/LuceneSearchFederated.java 2007-07-18 07:33:25 UTC (rev 7815)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -20,7 +20,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
******************************************************************************/
-package org.jboss.portal.search.lucene;
+package org.jboss.portal.search.impl.lucene;
import java.io.IOException;
import java.util.Iterator;
@@ -36,9 +36,10 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Searcher;
import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.impl.QueryImpl;
import org.jboss.portal.search.result.ResultSet;
import org.jboss.portal.search.result.impl.AbstractResult;
import org.jboss.portal.search.result.impl.SimpleResult;
@@ -47,7 +48,7 @@
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class LuceneSearchFederated implements SearchFederated
+public abstract class LuceneSearchFederated implements FederatedSearcher
{
private IndexWriter index;
@@ -126,6 +127,10 @@
return documents;
}
+ /**
+ * List of GenericDocument
+ * @return
+ */
public abstract List getDocuments();
public void destroy()
@@ -146,13 +151,10 @@
public ResultSet search(Query query)
{
ResultSet result = new ResultSet(this);
- String luceneQueryString = LuceneQueryConverter.convert(query);
- QueryParser parser = new QueryParser(defaultField, new StandardAnalyzer());
try
{
- org.apache.lucene.search.Query luceneQuery = parser.parse(luceneQueryString);
Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(luceneQuery);
+ Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
for (int i=0; i<hits.length(); i++)
{
result.add(new SimpleResult(id, hits.doc(i)));
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/Result.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.search.result;
+import org.jboss.portal.common.i18n.LocalizedString;
+
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
@@ -32,5 +34,7 @@
public ResultURL getURL();
- public String getTitle();
+ public LocalizedString getTitle();
+
+ public LocalizedString getType();
}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/ResultSet.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -24,7 +24,7 @@
import java.util.ArrayList;
-import org.jboss.portal.search.SearchFederated;
+import org.jboss.portal.search.FederatedSearcher;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -34,14 +34,14 @@
{
private static final long serialVersionUID = -334471675564695554L;
- private SearchFederated searchFederated;
+ private FederatedSearcher searchFederated;
- public ResultSet(SearchFederated searchFederated)
+ public ResultSet(FederatedSearcher searchFederated)
{
this.searchFederated = searchFederated;
}
- public SearchFederated getSearchFederated()
+ public FederatedSearcher getSearchFederated()
{
return searchFederated;
}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/AbstractResult.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.search.result.impl;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.result.Result;
import org.jboss.portal.search.result.ResultURL;
@@ -29,12 +30,14 @@
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public abstract class AbstractResult implements Result
+public abstract class AbstractResult implements Result, Comparable
{
private String federatedId;
- private String title;
+ private LocalizedString title;
+ private LocalizedString type;
+
private float score;
private ResultURL url;
@@ -69,14 +72,44 @@
this.score = score;
}
- public String getTitle()
+ public LocalizedString getTitle()
{
return title;
}
- public void setTitle(String title)
+ public void setTitle(LocalizedString title)
{
this.title = title;
}
+ public LocalizedString getType()
+ {
+ return type;
+ }
+
+ public void setType(LocalizedString type)
+ {
+ this.type = type;
+ }
+
+ public int compareTo(Object anotherResult) throws ClassCastException {
+ if (!(anotherResult instanceof Result))
+ {
+ throw new ClassCastException("Cannot mix Result with other stuff");
+ }
+ Result other = (Result)anotherResult;
+ float diff = other.getScore() - this.getScore();
+ if (diff == 0)
+ {
+ return 0;
+ }
+ else if (diff < 0)
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/JSFPortletResultURL.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result.impl;
+
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class JSFPortletResultURL extends PortletResultURL
+{
+
+ private String viewId;
+
+ public JSFPortletResultURL(String windowRef, String viewId, Map renderParameters)
+ {
+ super(windowRef, renderParameters);
+ this.viewId = viewId;
+ }
+
+ public String getViewId()
+ {
+ return viewId;
+ }
+
+ public void setViewId(String viewId)
+ {
+ this.viewId = viewId;
+ }
+
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/PortletResultURL.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,89 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.result.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+//import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.search.result.ResultURL;
+//import org.jboss.portal.server.request.URLContext;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PortletResultURL implements ResultURL
+{
+
+ private String windowRef;
+
+ private Map renderParameters;
+
+// private PortalObjectContainer portalObjectContainer;
+
+// private PortalNode portalNode;
+
+ public PortletResultURL(String windowRef, Map renderParameters)
+ {
+// this.portalObjectContainer = portalObjectContainer;
+// this.portalNode = portalNode;
+ this.windowRef = windowRef;
+ this.renderParameters = renderParameters;
+ if (renderParameters == null)
+ {
+ renderParameters = new HashMap();
+ }
+ }
+
+ public void addRenderParameter(String name, String value )
+ {
+ renderParameters.put(name, value);
+ }
+
+ public String getWindowRef()
+ {
+ return windowRef;
+ }
+
+ public Map getRenderParameters()
+ {
+ return renderParameters;
+ }
+
+ /*
+ public String getStringURL()
+ {
+ PortalObject targetPortalNode = portalObjectContainer.getObject(PortalObjectId.parse(windowRef, PortalObjectPath.CANONICAL_FORMAT));
+
+ return url.toString();
+ }
+ */
+ /*
+ public String getStringURL()
+ {
+
+ }
+ */
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResult.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -30,7 +30,7 @@
{
private Object value;
-
+
public SimpleResult(String federatedId, Object value)
{
super(federatedId);
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/result/impl/SimpleResultURL.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -37,7 +37,7 @@
this.url = url;
}
- public String getURL()
+ public String getStringURL()
{
return url;
}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -22,25 +22,88 @@
******************************************************************************/
package org.jboss.portal.search.test;
+import junit.framework.TestCase;
+
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
+import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.impl.StandardQueryConverter;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
-import junit.framework.TestCase;
-
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
public class ConverterTest extends TestCase
{
-
+/*
public void testOptionalKeyword()
{
Query query = QueryConverter.convert("test");
KeywordQueryTerm term = (KeywordQueryTerm)query.getOptionalTerms().get(0);
assertEquals("test", term.getKeyWord());
}
+*/
-
+ public void testJCRConverter()
+ {
+ org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id", "1"));
+ Query query = new LuceneQuery(luceneQuery);
+
+ StandardQueryConverter standardConverter = new StandardQueryConverter();
+ try
+ {
+ query = standardConverter.convert(query);
+ }
+ catch (QueryConversionException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+ QueryConverter converter = new JCRQueryConverter();
+ try
+ {
+ JCRQuery xpath = (JCRQuery)converter.convert(query);
+ assertEquals("//*[jcr:contains(., '1')]", xpath.toString());
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void testJCRConverterMultipleTerms()
+ {
+ Query query = new QueryImpl("foo bar");
+
+ StandardQueryConverter standardConverter = new StandardQueryConverter();
+ try
+ {
+ query = standardConverter.convert(query);
+ }
+ catch (QueryConversionException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+ QueryConverter converter = new JCRQueryConverter();
+ try
+ {
+ JCRQuery xpath = (JCRQuery)converter.convert(query);
+ assertEquals("//*[jcr:contains(., 'foo'), jcr:contains(., 'bar')]", xpath.toString());
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
}
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java (from rev 7815, branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java)
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.search.test;
+
+import java.util.Locale;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.FederatedIndexer;
+import org.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.result.ResultSet;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class DummyFederatedSearch implements FederatedSearcher, FederatedIndexer
+{
+
+ private Info info;
+
+ public DummyFederatedSearch()
+ {
+ info = new Info();
+ }
+
+ public void createIndex() throws IndexingException
+ {
+ info.setStatus(Info.Status.STARTED);
+ // Do stuff in a thread
+ info.setStatus(Info.Status.AVAILABLE);
+ }
+
+ public void destroyIndex() throws IndexingException
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return "DummySearchFederated";
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+ public String getMarkup(ResultSet results, int markupLevel)
+ {
+ return null;
+ }
+
+ public ResultSet search(Query query)
+ {
+ ResultSet results = new ResultSet(this);
+ results.add(new SimpleResult(getId(), "Result 1"));
+ results.add(new SimpleResult(getId(), "Result 2"));
+ results.add(new SimpleResult(getId(), "Result 3"));
+ return results;
+ }
+
+ public LocalizedString getDisplayName()
+ {
+ return null;
+ }
+
+}
Deleted: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummySearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -1,89 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.search.test;
-
-import java.util.Locale;
-
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.SearchFederated;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.result.ResultSet;
-import org.jboss.portal.search.result.impl.SimpleResult;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class DummySearchFederated implements SearchFederated
-{
-
- private Info info;
-
- public DummySearchFederated()
- {
- info = new Info();
- }
-
- public void create() throws IndexingException
- {
- info.setStatus(Info.Status.STARTED);
- info.setStatus(Info.Status.AVAILABLE);
- }
-
- public void destroy() throws IndexingException
- {
- info.setStatus(Info.Status.STOPPED);
- }
-
- public String getId()
- {
- return "DummySearchFederated";
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public String getMarkup(ResultSet results, int markupLevel)
- {
- return null;
- }
-
- public ResultSet search(Query query)
- {
- ResultSet results = new ResultSet(this);
- results.add(new SimpleResult(getId(), "Result 1"));
- results.add(new SimpleResult(getId(), "Result 2"));
- results.add(new SimpleResult(getId(), "Result 3"));
- return results;
- }
-
- public String getName(Locale locale)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -24,10 +24,15 @@
import java.util.List;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SearchingException;
+import org.jboss.portal.search.federation.IndexFederation;
import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.federation.impl.IndexFederationService;
import org.jboss.portal.search.federation.impl.SearchFederationService;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
import org.jboss.portal.search.result.ResultSet;
import org.jboss.portal.search.result.impl.SimpleResult;
@@ -39,17 +44,20 @@
*/
public class FederationTest extends TestCase
{
- public void test01()
+ public void test01() throws SearchingException
{
- SearchFederation federation = new SearchFederationService();
- DummySearchFederated federated = new DummySearchFederated();
- federation.register(federated);
- federation.reindexAll();
+ SearchFederation searchfederation = new SearchFederationService();
+ DummyFederatedSearch federatedSearch = new DummyFederatedSearch();
+ searchfederation.register(federatedSearch);
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
+ IndexFederation indexfederation = new IndexFederationService();
+ indexfederation.register(federatedSearch);
+ indexfederation.reindexAll();
- List list = federation.search(query);
+ org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id", "1"));
+ Query query = new LuceneQuery(luceneQuery);
+
+ List list = searchfederation.search(query);
ResultSet results = (ResultSet)list.get(0);
assertEquals("Result 1", (((SimpleResult)results.getResult(0)).getValue()));
assertEquals("Result 2", (((SimpleResult)results.getResult(1)).getValue()));
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -22,14 +22,6 @@
******************************************************************************/
package org.jboss.portal.search.test;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.federated.lucene.LuceneQueryConverter;
-import org.jboss.portal.search.federated.lucene.LuceneSearchFederated;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.BetweenDatesTerm;
-import org.jboss.portal.search.query.impl.FieldQueryTerm;
-import org.jboss.portal.search.result.ResultSet;
-
import junit.framework.TestCase;
/**
@@ -39,6 +31,7 @@
public class LuceneQueryTest extends TestCase
{
+ /*
public void test01()
{
Query query = new Query();
@@ -67,5 +60,5 @@
System.out.println(fed.getMarkup(results, 0));
assertEquals("Id:1 Id:1 cat ", fed.getMarkup(results, 0));
}
-
+ */
}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-09 12:45:50 UTC (rev 7881)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-09 12:50:21 UTC (rev 7882)
@@ -28,7 +28,8 @@
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.jboss.portal.search.federated.lucene.LuceneSearchFederated;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.impl.lucene.LuceneSearchFederated;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -62,7 +63,7 @@
return null;
}
- public String getName(Locale locale)
+ public LocalizedString getDisplayName()
{
// TODO Auto-generated method stub
return null;
16 years, 9 months
JBoss Portal SVN: r7881 - in branches/JBoss_Portal_Branch_2_6: cms/src/main/org/jboss/portal/cms and 16 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 08:45:50 -0400 (Thu, 09 Aug 2007)
New Revision: 7881
Added:
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultCommandFactoryService.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultURLFactory.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/PropertyResolver.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/url/
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/url/SearchUrlFactory.java
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search.properties
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search_it.properties
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/faces-config.xml
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsf/
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsf/index.xhtml
Removed:
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchConstants.java
branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchPortlet.java
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource_it.properties
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsp/
Modified:
branches/JBoss_Portal_Branch_2_6/cms/.classpath
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResult.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResultURL.java
branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java
branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
branches/JBoss_Portal_Branch_2_6/core-search/.classpath
branches/JBoss_Portal_Branch_2_6/core-search/build.xml
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-sar/META-INF/jboss-service.xml
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jboss-portlet.xml
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/portlet.xml
branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/web.xml
Log:
- Refactored search service
- Started JSF Search portlet
Modified: branches/JBoss_Portal_Branch_2_6/cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-09 12:45:50 UTC (rev 7881)
@@ -38,10 +38,10 @@
<classpathentry combineaccessrules="false" kind="src" path="/portlet"/>
<classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/identity"/>
- <classpathentry combineaccessrules="false" kind="src" path="/search"/>
<classpathentry combineaccessrules="false" kind="src" path="/workflow"/>
<classpathentry kind="lib" path="/thirdparty/jackrabbit/lib/jackrabbit-core.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/security"/>
<classpathentry kind="lib" path="/thirdparty/jbpm/jaronly/lib/jbpm.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/search"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -29,7 +29,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
/**
* Factory to create commands for the cms service.
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -53,7 +53,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -36,8 +36,11 @@
import org.jboss.portal.cms.impl.FileImpl;
import org.jboss.portal.cms.impl.jcr.JCRCommand;
import org.jboss.portal.cms.model.File;
-import org.jboss.portal.search.federated.jcr.JCRQueryConverter;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConverter;
+import org.jboss.portal.search.impl.StandardQueryConverter;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -62,33 +65,42 @@
Workspace workspace = session.getWorkspace();
QueryManager queryManager;
List files = new ArrayList();
+ String queryString = null;
try
{
queryManager = workspace.getQueryManager();
- String queryString = JCRQueryConverter.convert(query);
- if (! "".equals(queryString))
+ StandardQueryConverter standardConverter = new StandardQueryConverter();
+ query = standardConverter.convert(query);
+
+ QueryConverter converter = new JCRQueryConverter();
+ if (query != null)
{
- javax.jcr.query.Query jcrQuery = queryManager.createQuery(queryString, javax.jcr.query.Query.XPATH);
- QueryResult queryResult=jcrQuery.execute();
- NodeIterator nodeIterator = queryResult.getNodes();
-
- while (nodeIterator.hasNext())
+ queryString = ((JCRQuery) converter.convert(query)).getJcrQuery();
+
+ if (!"".equals(queryString) && query != null)
{
- Node node;
- node = nodeIterator.nextNode().getParent();
- File file = new FileImpl();
- file.setBasePath(node.getPath());
- file.setCreationDate(node.getProperty("jcr:created").getDate().getTime());
- file.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
- file.setName(node.getName());
- files.add(file);
+ javax.jcr.query.Query jcrQuery = queryManager.createQuery(queryString, javax.jcr.query.Query.XPATH);
+ QueryResult queryResult = jcrQuery.execute();
+ NodeIterator nodeIterator = queryResult.getNodes();
+
+ while (nodeIterator.hasNext())
+ {
+ Node node;
+ node = nodeIterator.nextNode().getParent();
+ File file = new FileImpl();
+ file.setBasePath(node.getPath());
+ file.setCreationDate(node.getProperty("jcr:created").getDate().getTime());
+ file.setLastModified(node.getProperty("jcr:lastModified").getDate().getTime());
+ file.setName(node.getName());
+ files.add(file);
+ }
}
- }
+ }
}
catch (Exception e)
{
- throw new CMSException("Cannot query the CMS", e);
+ throw new CMSException("Cannot query the CMS with query: " + queryString, e);
}
return files;
}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -22,35 +22,30 @@
******************************************************************************/
package org.jboss.portal.cms.search;
+import java.util.Iterator;
+import java.util.List;
+
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.File;
-import org.jboss.portal.search.IndexingException;
-import org.jboss.portal.search.federation.Info;
-import org.jboss.portal.search.impl.GenericSearchFederated;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
import org.jboss.portal.search.result.ResultSet;
-import java.util.Iterator;
-import java.util.List;
-
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class CMSFederatedSearch extends GenericSearchFederated
+public class CMSFederatedSearch extends AbstractFederatedSearcher
{
private CMS cms;
- private Info info;
- private String id;
private String urlPrefix;
public CMSFederatedSearch(String id)
{
- this.id = id;
- info = new Info();
- info.setStatus(Info.Status.AVAILABLE);
-
+ setId(id);
+ setDisplayName(new LocalizedString("Content Management System"));
this.urlPrefix = "portal/content";
}
@@ -59,28 +54,6 @@
this.cms = cms;
}
- public void create() throws IndexingException
- {
- info.setStatus(Info.Status.AVAILABLE);
- }
-
- public void destroy() throws IndexingException
- {
- // Indexing should be managed by the JCR implementation
-
- }
-
- public Info getInfo()
- {
- return info;
- }
-
- public String getMarkup(ResultSet results, int markupLevel)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public ResultSet search(Query query)
{
Command searchCommand = cms.getCommandFactory().createSearchCommand(query);
@@ -96,9 +69,5 @@
return results;
}
- public String getId()
- {
- return id;
- }
}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResult.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResult.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResult.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -23,6 +23,7 @@
package org.jboss.portal.cms.search;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.result.Result;
import org.jboss.portal.search.result.ResultURL;
@@ -52,17 +53,21 @@
{
return url;
}
-
- public String getTitle()
+
+ public LocalizedString getTitle()
{
if (file.getTitle() != null)
{
- return file.getTitle();
+ return new LocalizedString(file.getTitle());
}
else
{
- return file.getName();
+ return new LocalizedString(file.getName());
}
}
+ public LocalizedString getType()
+ {
+ return new LocalizedString("CMS");
+ }
}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResultURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResultURL.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSResultURL.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -23,25 +23,18 @@
package org.jboss.portal.cms.search;
import org.jboss.portal.cms.model.File;
-import org.jboss.portal.search.result.ResultURL;
+import org.jboss.portal.search.result.impl.SimpleResultURL;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class CMSResultURL implements ResultURL
+public class CMSResultURL extends SimpleResultURL
{
- private File file;
- private String prefix;
public CMSResultURL(String prefix, File file)
{
- this.file = file;
- this.prefix = prefix;
+ super("/" + prefix + file.getBasePath());
}
- public String toString()
- {
- return "/" + prefix + file.getBasePath();
- }
}
Modified: branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -22,20 +22,17 @@
******************************************************************************/
package org.jboss.portal.test.cms.commands;
+import java.util.List;
+
import junit.framework.TestSuite;
+
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.Command;
-import org.jboss.portal.cms.impl.ContentImpl;
-import org.jboss.portal.cms.impl.FileImpl;
-import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portal.search.query.impl.KeywordQueryTerm;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.QueryImpl;
-import java.util.List;
-import java.util.Locale;
-
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
*/
@@ -54,8 +51,7 @@
/** Tests retrieval of the version labeled LIVE. */
public void testFileGet() throws CMSException
{
- Query query = new Query();
- query.addOptionalTerm(new KeywordQueryTerm("risks"));
+ Query query = new QueryImpl("risks");
Command searchCMD = service.getCommandFactory().createSearchCommand(query);
List list = (List)service.execute(searchCMD);
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-09 12:45:50 UTC (rev 7881)
@@ -18,11 +18,11 @@
<classpathentry combineaccessrules="false" kind="src" path="/theme"/>
<classpathentry combineaccessrules="false" kind="src" path="/workflow"/>
<classpathentry kind="lib" path="/thirdparty/apache-fileupload/lib/commons-fileupload.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/search"/>
<classpathentry combineaccessrules="false" kind="src" path="/security"/>
<classpathentry kind="lib" path="/thirdparty/jbpm/jaronly/lib/jbpm.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-myfaces/lib/myfaces-api.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/core-admin"/>
<classpathentry kind="lib" path="/thirdparty/hibernate/lib/hibernate3.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/search"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/build.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -93,6 +93,7 @@
<path refid="hibernate.hibernate.classpath"/>
<path refid="apache.ant.classpath"/>
<path refid="apache.myfaces.classpath"/>
+ <path refid="apache.lucene.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="junit.junit.classpath"/>
<path refid="sun.servlet.classpath"/>
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/CMSPortlet.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -169,7 +169,7 @@
try
{
SearchFederation searchFederationService = (SearchFederation)getPortletContext().getAttribute("SearchFederationService");
- if (searchFederationService.getSearchFederated(CMSConstants.SEARCH_ID) == null)
+ if (searchFederationService.getFederatedSearcher(CMSConstants.SEARCH_ID) == null)
{
CMSFederatedSearch federatedSearch = new CMSFederatedSearch(CMSConstants.SEARCH_ID);
federatedSearch.setCMS(CMSService);
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -71,8 +71,8 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
-import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.query.Query;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.QueryImpl;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -309,8 +309,7 @@
rRes.setContentType("text/html");
String textQuery = rReq.getParameter("search");
-
- Query query = QueryConverter.convert(textQuery);
+ Query query = new QueryImpl(textQuery);
List files;
try
{
Modified: branches/JBoss_Portal_Branch_2_6/core-search/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/.classpath 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/.classpath 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,11 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="org/jboss/portal/search/" kind="src" path="src/main"/>
+ <classpathentry excluding="org/jboss/portal/search/|services/" kind="src" path="src/main"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar" sourcepath="/JBoss_AS_4.0.5/system/src/main"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar" sourcepath="/JBoss_AS_4.0.5/jmx/src/main"/>
+ <classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-common.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-lucene/lib/lucene.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/apache-myfaces/lib/myfaces-api.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/portlet"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/server"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/common"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/jems"/>
<classpathentry combineaccessrules="false" kind="src" path="/search"/>
- <classpathentry combineaccessrules="false" kind="src" path="/portlet"/>
- <classpathentry combineaccessrules="false" kind="src" path="/cms"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/faces"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Modified: branches/JBoss_Portal_Branch_2_6/core-search/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/build.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/build.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -92,6 +92,7 @@
<path refid="jbossas/core.libs.classpath"/>
<path refid="hibernate.hibernate.classpath"/>
<path refid="apache.ant.classpath"/>
+ <path refid="apache.lucene.classpath"/>
<path refid="apache.myfaces.classpath"/>
<path refid="apache.log4j.classpath"/>
<path refid="junit.junit.classpath"/>
@@ -126,6 +127,7 @@
<path refid="jboss.portal-portlet.classpath"/>
<path refid="jboss.portal-jems.classpath"/>
<path refid="jboss.portal-identity.classpath"/>
+ <path refid="jboss.portal-faces.classpath"/>
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-security.classpath"/>
<path refid="jboss.portal-theme.classpath"/>
@@ -218,25 +220,50 @@
<mkdir dir="${build.lib}"/>
- <!-- portal-core-search-lib.jar -->
- <jar jarfile="${build.lib}/portal-core-search-lib.jar">
- <fileset dir="${build.classes}">
+ <!-- portal-core-search-ui-lib.jar -->
+ <jar jarfile="${build.lib}/portal-core-search-ui-lib.jar">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/core/search/ui/**">
</fileset>
</jar>
- <!-- portal-search.sar -->
- <copy todir="${build.resources}/portal-search">
- <!--fileset dir="${source.bin}/portal-search-sar"/-->
- <fileset dir="${build.resources}/portal-search-sar"/>
+ <!-- portal-core-search-service-lib.jar -->
+ <jar jarfile="${build.lib}/portal-core-search-service-lib.jar">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/core/search/service/**">
+ </fileset>
+ </jar>
+
+ <!-- portal-admin.war -->
+ <copy todir="${build.resources}/portal-search-war/WEB-INF/lib2">
+ <fileset dir="${build.lib}" includes="portal-core-search-ui-lib.jar"/>
+ <fileset dir="${apache.myfaces.lib}" includes="myfaces-api.jar,myfaces-impl.jar,jstl.jar"/>
+ <fileset dir="${jboss.portal-faces.root}/lib" includes="portal-faces-lib.jar"/>
+ <fileset dir="../core-admin/src/etc/sun-jsf" includes="jsf-example.jar"/>
+ <fileset dir="${facelets.facelets.lib}" includes="jsf-facelets.jar"/>
+ <fileset dir="${el.el.lib}" includes="el-api.jar,el-ri.jar"/>
+ <fileset dir="${commons.el.lib}" includes="commons-el.jar"/>
+ <fileset dir="${apache.beanutils.lib}" includes="commons-beanutils.jar"/>
+ <fileset dir="${apache.digester.lib}" includes="commons-digester.jar"/>
+ <fileset dir="${apache.lang.lib}" includes="commons-lang.jar"/>
+ </copy>
+
+
+ <!--copy todir="${build.resources}/portal-search-war">
+ <fileset dir="${source.bin}/portal-search-war"/>
+ </copy-->
+
+ <!-- portal-search.war -->
+ <copy todir="${build.resources}/portal-search-war">
+ <fileset dir="${build.resources}/portal-search-war"/>
</copy>
- <copy todir="${build.resources}/portal-search/lib">
- <fileset dir="${build.lib}" includes="portal-core-search-lib.jar"/>
- <fileset dir="${jboss.portal-search.root}/lib" includes="portal-search-lib.jar"/>
+
+ <copy todir="${build.resources}/portal-search-sar/lib">
+ <fileset dir="${build.lib}" includes="portal-core-search-service-lib.jar"/>
+ <!--fileset dir="${jboss.portal-search.root}/lib" includes="portal-search-lib.jar"/-->
+ <fileset dir="${apache.lucene.lib}" includes="lucene.jar"/>
+ <fileset dir="${jboss.portal-faces.root}/lib" includes="portal-faces-loader-lib.jar"/>
</copy>
- <!-- portal-search.war -->
- <copy todir="${build.resources}/portal-search/portal-search.war">
- <!--fileset dir="${source.bin}/portal-search-war"/-->
+ <copy todir="${build.resources}/portal-search.sar/portal-search.war">
<fileset dir="${build.resources}/portal-search-war"/>
</copy>
@@ -249,14 +276,14 @@
<!-- Build configurations -->
<copy todir="${build.resources}/portal-search.sar">
- <fileset dir="${build.resources}/portal-search" excludes="**/*.xml"/>
+ <fileset dir="${build.resources}/portal-search-sar" excludes="**/*.xml"/>
</copy>
<copy todir="${build.resources}/portal-search.sar">
<filterset>
<filtersfile file="../build/etc/single.properties"/>
</filterset>
- <fileset dir="${build.resources}/portal-search" includes="**/*.xml"/>
+ <fileset dir="${build.resources}/portal-search-sar" includes="**/*.xml"/>
</copy>
<!-- Build archives -->
<implode
Deleted: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchConstants.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchConstants.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchConstants.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,35 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.search;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class SearchConstants
-{
- public static final String OP_DOSEARCH = "do_search";
- public static final String OP_VIEWSEARCHRESULTS = "view_search_results";
- public static String SEARCH_JSP_PATH = "/WEB-INF/jsp";
-
-}
Deleted: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchPortlet.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchPortlet.java 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/SearchPortlet.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,106 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.search;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.portlet.ActionRequest;
-import javax.portlet.ActionResponse;
-import javax.portlet.PortletException;
-
-import org.jboss.portal.api.node.PortalNode;
-import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.federation.SearchFederation;
-import org.jboss.portal.search.query.Query;
-import org.jboss.portlet.JBossPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
-
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class SearchPortlet extends JBossPortlet
-{
-
- private SearchFederation searchService;
-
- public void init()
- {
- searchService = (SearchFederation)getPortletContext().getAttribute("SearchService");
- }
-
-
- public void doView(JBossRenderRequest rReq, JBossRenderResponse rRes) throws PortletException, IOException
- {
- rRes.setContentType("text/html");
- String op = rReq.getParameter("op");
-
- if ((op == null) || ("".equals(op)))
- {
- javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(SearchConstants.SEARCH_JSP_PATH + "/search.jsp");
- try
- {
- prd.include(rReq, rRes);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- else if (op.equals(SearchConstants.OP_VIEWSEARCHRESULTS))
- {
- rRes.setContentType("text/html");
-
- String textQuery = rReq.getParameter("search");
-
- Query query = QueryConverter.convert(textQuery);
-
- List results = searchService.search(query);
-
- rReq.setAttribute("results", results);
-
-
- PortalNode root = rReq.getPortalNode().getRoot();
-
- rReq.setAttribute("rootNode", root);
- rReq.setAttribute("JBossRenderResponse", rRes);
-
-
- javax.portlet.PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher(SearchConstants.SEARCH_JSP_PATH + "/viewResults.jsp");
- prd.include(rReq, rRes);
- }
-
- }
-
- public void processAction(ActionRequest aReq, ActionResponse aRes)
- {
- String search = (String) aReq.getParameter("search");
-
- aRes.setRenderParameter("search", search);
- aRes.setRenderParameter("op", SearchConstants.OP_VIEWSEARCHRESULTS);
-
- }
-}
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultCommandFactoryService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultCommandFactoryService.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultCommandFactoryService.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.search.service;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.mapper.AbstractCommandFactory;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.core.model.portal.command.action.InvokePortletWindowRenderCommand;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.server.ServerInvocation;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchResultCommandFactoryService extends AbstractCommandFactory
+{
+ private static String TARGET_WINDOW = "targetWindow";
+
+ public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host, String contextPath, String requestPath)
+ {
+ Map parameters = invocation.getServerContext().getQueryParameterMap();
+
+ PortletParametersStateString renderParameters = new PortletParametersStateString();
+
+ String targetWindowRef = null;
+ Iterator it = parameters.keySet().iterator();
+ while (it.hasNext())
+ {
+ String key = (String)it.next();
+ if (key.equals(TARGET_WINDOW))
+ {
+ targetWindowRef = ((String[])parameters.get(key))[0];
+ }
+ else
+ {
+ renderParameters.setValue(key, ((String[])parameters.get(key))[0]);
+ }
+ }
+
+ PortalObjectId targetWindowId = PortalObjectId.parse(targetWindowRef, PortalObjectPath.LEGACY_FORMAT);
+
+ // Perform a render URL on the target window
+ return new InvokePortletWindowRenderCommand(targetWindowId, Mode.VIEW, WindowState.MAXIMIZED, renderParameters);
+
+ }
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultURLFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultURLFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/service/SearchResultURLFactory.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,79 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.search.service;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.result.ResultURL;
+import org.jboss.portal.search.result.impl.PortletResultURL;
+import org.jboss.portal.search.result.impl.SimpleResultURL;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchResultURLFactory extends AbstractJBossService
+{
+ private String path;
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+ public String getURL(ResultURL resultURL, String contextPath)
+ {
+ if (resultURL instanceof SimpleResultURL)
+ {
+ return ((SimpleResultURL)resultURL).getStringURL();
+ }
+ else if (resultURL instanceof PortletResultURL)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(path + "?");
+ PortletResultURL portletResultURL = (PortletResultURL)resultURL;
+
+ buffer.append("targetWindow=" + portletResultURL.getWindowRef());
+
+ Map map = portletResultURL.getRenderParameters();
+ Iterator it = map.keySet().iterator();
+ while (it.hasNext())
+ {
+ buffer.append("&");
+ String key = (String)it.next();
+ buffer.append(key + "=" + map.get(key));
+ }
+ return buffer.toString();
+ }
+ return null;
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/PropertyResolver.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/PropertyResolver.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/PropertyResolver.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.search.ui;
+
+import java.util.Locale;
+
+import javax.faces.context.FacesContext;
+
+import org.jboss.portal.common.i18n.LocalizedString;
+import org.jboss.portal.core.search.service.SearchResultURLFactory;
+import org.jboss.portal.faces.el.DelegatingPropertyResolver;
+import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
+import org.jboss.portal.faces.el.decorator.SimpleBeanDecorator;
+import org.jboss.portal.search.result.Result;
+import org.jboss.portal.search.result.ResultURL;
+import org.jboss.portal.search.result.impl.AbstractResult;
+import org.jboss.portal.search.result.impl.SimpleResult;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class PropertyResolver extends DelegatingPropertyResolver
+{
+
+ public PropertyResolver()
+ {
+ init();
+ }
+
+ public PropertyResolver(javax.faces.el.PropertyResolver delegate)
+ {
+ super(delegate);
+
+ //
+ init();
+ }
+
+
+ private void init()
+ {
+ SimpleBeanDecorator resultURLDecorator = new SimpleBeanDecorator();
+ resultURLDecorator.setProperty("value", new AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean)
+ {
+ ResultURL resultURL = (ResultURL)bean;
+ SearchResultURLFactory urlFactory = new SearchResultURLFactory();
+ urlFactory.setPath("/portal/search");
+ return (urlFactory.getURL(resultURL, FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()));
+ }
+ });
+ registerDecorator(ResultURL.class, resultURLDecorator);
+
+ SimpleBeanDecorator localizedStringDecorator = new SimpleBeanDecorator();
+ localizedStringDecorator.setProperty("value", new AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean)
+ {
+ LocalizedString string = (LocalizedString)bean;
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ return string.getString(locale, true);
+ }
+ });
+ registerDecorator(LocalizedString.class, localizedStringDecorator);
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,202 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.search.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+import javax.faces.model.ListDataModel;
+import javax.faces.model.SelectItem;
+import javax.portlet.PortletContext;
+
+import org.jboss.portal.core.search.service.SearchResultURLFactory;
+import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SearchingException;
+import org.jboss.portal.search.federation.SearchFederation;
+import org.jboss.portal.search.identity.UserSearcher;
+import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.result.Result;
+import org.jboss.portal.search.result.ResultSet;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchBean
+{
+ public String textString;
+
+ private SearchFederation searchService;
+
+ private List selectedFederatedSearchers;
+
+ private int nbMaxResults = 20;
+
+ private int nbResults = 0;
+
+ private ListDataModel resultsDataModel;
+
+ public SearchBean()
+ {
+ PortletContext portletContext = (PortletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();
+ searchService = (SearchFederation) portletContext.getAttribute("SearchService");
+ org.jboss.portal.search.identity.UserSearcher searcher = new UserSearcher();
+ if (searchService.getFederatedSearcher(searcher.getId()) == null)
+ {
+ searchService.register(searcher);
+ }
+ }
+
+ public List getSearcher()
+ {
+ return searchService.getFederatedSearcherList();
+ }
+
+ public String getTextString()
+ {
+ return textString;
+ }
+
+ public void setTextString(String textString)
+ {
+ this.textString = textString;
+ }
+
+ public int getNbResults()
+ {
+ return nbResults;
+ }
+
+ public DataModel getResults()
+ {
+ return resultsDataModel;
+ }
+
+ public SelectItem[] getFederatedSearchers()
+ {
+ List list = searchService.getFederatedSearcherList();
+
+ SelectItem[] result = new SelectItem[list.size()];
+
+ int i = 0;
+ Iterator it = list.iterator();
+ while (it.hasNext())
+ {
+ FederatedSearcher searcher = (FederatedSearcher)it.next();
+ result[i] = new SelectItem(searcher.getId(), searcher.getDisplayName().getValue(FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(), true).getString());
+ i++;
+ }
+
+ return result;
+ }
+
+ public void setSelectedFederatedSearchers(List list)
+ {
+ selectedFederatedSearchers = list;
+ }
+
+
+ public List getSelectedFederatedSearchers()
+ {
+ if (selectedFederatedSearchers == null)
+ {
+ selectedFederatedSearchers = new ArrayList();
+ Iterator it = searchService.getFederatedSearcherList().iterator();
+ while (it.hasNext())
+ {
+ FederatedSearcher searcher = (FederatedSearcher)it.next();
+ selectedFederatedSearchers.add(searcher.getId());
+ }
+ }
+ return selectedFederatedSearchers;
+ }
+
+ public void search()
+ {
+ List results = null;
+ Query query;
+ try
+ {
+ query = new QueryImpl(textString);
+ results = searchService.search(query, selectedFederatedSearchers);
+ }
+ catch (SearchingException e)
+ {
+ // FIXME
+ e.printStackTrace();
+ }
+
+ setResultsDataModel(results);
+ setNbResults(results);
+
+
+ }
+
+
+ private void setResultsDataModel(List results)
+ {
+ List returnList = new ArrayList();
+ if (results != null)
+ {
+ Iterator it = results.iterator();
+ int i=0;
+ while (it.hasNext())
+ {
+ ResultSet resultSet = (ResultSet)it.next();
+ Iterator itResults = resultSet.iterator();
+ while (itResults.hasNext() && i < nbMaxResults)
+ {
+ Result result = (Result)itResults.next();
+ returnList.add(result);
+ i++;
+ }
+ }
+ }
+ resultsDataModel = new ListDataModel(returnList);
+ }
+
+ private void setNbResults(List results)
+ {
+ int returnValue = 0;
+ if (results != null)
+ {
+ Iterator it = results.iterator();
+ while (it.hasNext())
+ {
+ ResultSet resultSet = (ResultSet)it.next();
+ returnValue += resultSet.size();
+ }
+ nbResults = returnValue;
+ }
+ else
+ {
+ nbResults = 0;
+ }
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/url/SearchUrlFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/url/SearchUrlFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/url/SearchUrlFactory.java 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.search.ui.url;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SearchUrlFactory
+{
+
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-sar/META-INF/jboss-service.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-sar/META-INF/jboss-service.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -31,5 +31,37 @@
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
</mbean>
+
+ <mbean
+ code="org.jboss.portal.core.search.service.SearchResultCommandFactoryService"
+ name="portal:commandFactory=SearchResult"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+ <mbean
+ code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
+ name="portal:commandFactory=Delegate,path=search"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="Path">/search</attribute>
+ <depends
+ optional-attribute-name="DelegatingFactory"
+ proxy-type="attribute">portal:commandFactory=Delegating</depends>
+ <depends
+ optional-attribute-name="DelegateFactory"
+ proxy-type="attribute">portal:commandFactory=SearchResult</depends>
+ </mbean>
+
+ <!-- mbean
+ code="org.jboss.portal.core.search.service.SearchResultURLFactory"
+ name="portal:urlFactory=SearchResult"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <attribute name="Path">portal/search</attribute>
+ </mbean-->
+
</server>
Deleted: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource.properties 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource.properties 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,25 +0,0 @@
-################################################################################
-# JBoss, a division of Red Hat #
-# Copyright 2006, Red Hat Middleware, LLC, and individual #
-# contributors as indicated by the @authors tag. See the #
-# copyright.txt in the distribution for a full listing of #
-# individual contributors. #
-# #
-# This is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU Lesser General Public License as #
-# published by the Free Software Foundation; either version 2.1 of #
-# the License, or (at your option) any later version. #
-# #
-# This software is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
-# Lesser General Public License for more details. #
-# #
-# You should have received a copy of the GNU Lesser General Public #
-# License along with this software; if not, write to the Free #
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
-# 02110-1301 USA, or see the FSF site: http://www.fsf.org. #
-################################################################################
-
-SEARCH_SEARCH=Search
-
\ No newline at end of file
Deleted: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource_it.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource_it.properties 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Resource_it.properties 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,25 +0,0 @@
-################################################################################
-# JBoss, a division of Red Hat #
-# Copyright 2006, Red Hat Middleware, LLC, and individual #
-# contributors as indicated by the @authors tag. See the #
-# copyright.txt in the distribution for a full listing of #
-# individual contributors. #
-# #
-# This is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU Lesser General Public License as #
-# published by the Free Software Foundation; either version 2.1 of #
-# the License, or (at your option) any later version. #
-# #
-# This software is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
-# Lesser General Public License for more details. #
-# #
-# You should have received a copy of the GNU Lesser General Public #
-# License along with this software; if not, write to the Free #
-# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA #
-# 02110-1301 USA, or see the FSF site: http://www.fsf.org. #
-################################################################################
-
-SEARCH_SEARCH=Ricerca
-
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search.properties (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search.properties 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,5 @@
+advancedSearch=Advanced Search
+search=Search
+noResult=No result was found
+oneResult=A unique result was found
+nbResults={0} results were found
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search_it.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search_it.properties (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/classes/Search_it.properties 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1 @@
+search=Ricerca
\ No newline at end of file
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/faces-config.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/faces-config.xml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/faces-config.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE faces-config PUBLIC
+ "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
+ "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
+<faces-config>
+
+ <application>
+ <property-resolver>org.jboss.portal.core.search.ui.PropertyResolver</property-resolver>
+ <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
+ </application>
+
+ <managed-bean>
+ <managed-bean-name>search</managed-bean-name>
+ <managed-bean-class>org.jboss.portal.core.search.ui.SearchBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+
+ <!-- navigation-rule>
+ <navigation-case>
+ <from-outcome>viewResults</from-outcome>
+ <to-view-id>/WEB-INF/jsf/viewResults.xhtml</to-view-id>
+ </navigation-case>
+ </navigation-rule -->
+
+</faces-config>
Modified: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jboss-portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jboss-portlet.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jboss-portlet.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -31,6 +31,19 @@
<transaction>
<trans-attribute>Required</trans-attribute>
</transaction>
+ <header-content>
+ <script type="text/javascript" language="javascript">
+ function hideShow(id)
+ {
+ var navpoint = document.getElementById(id);
+ if (navpoint.className == 'hidden') {
+ navpoint.className = 'shown';
+ } else {
+ navpoint.className = 'hidden';
+ }
+ }
+ </script>
+ </header-content>
</portlet>
<service>
<service-name>SearchService</service-name>
Added: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsf/index.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsf/index.xhtml (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/jsf/index.xhtml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -0,0 +1,57 @@
+<div
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:c="http://java.sun.com/jstl/core">
+
+ <f:loadBundle var="bundle" basename="Search" />
+
+ <h:form>
+ <h:commandButton
+ type="reset"
+ class="portlet-form-button"
+ value="#{bundle.advancedSearch}"
+ immediate="true"
+ onclick="hideShow('advanced');"/>
+ </h:form>
+
+ <h:form>
+
+ <div id="advanced" class="hidden">
+ <h:outputText value="#{bundle.advancedSearch}:"/>
+ <h:selectManyCheckbox value="#{search.selectedFederatedSearchers}">
+ <f:selectItems value="#{search.federatedSearchers}"/>
+ </h:selectManyCheckbox>
+ </div>
+
+ <br/>
+
+ <h:inputText styleClass="portlet-form-input-field"
+ value="#{search.textString}"/>
+
+ <h:commandButton action="#{search.search}"
+ value="#{bundle.search}"
+ styleClass="portlet-form-button"/>
+
+ </h:form>
+
+ <br/>
+
+ <h:outputText value="#{bundle.noResult}" rendered="#{search.nbResults == 0 and not empty search.textString}"/>
+ <h:outputFormat value="#{bundle.oneResult}" rendered="#{search.nbResults == 1}">
+ <f:param value="#{search.nbResults}"/>
+ </h:outputFormat>
+ <h:outputFormat value="#{bundle.nbResults}" rendered="#{search.nbResults > 1}">
+ <f:param value="#{search.nbResults}"/>
+ </h:outputFormat>
+
+ <h:dataTable value="#{search.results}" var="result">
+ <h:column>
+ <h:outputText value="#{result.type.value}"/>
+ </h:column>
+ <h:column>
+ <h:outputLink value="#{result.URL.value}"><h:outputText value="#{result.title.value}"/></h:outputLink>
+ </h:column>
+ </h:dataTable>
+</div>
Modified: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/portlet.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/portlet.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/portlet.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -32,7 +32,11 @@
<portlet-name>SearchPortlet</portlet-name>
<display-name>Search Portlet</display-name>
- <portlet-class>org.jboss.portal.core.search.SearchPortlet</portlet-class>
+ <portlet-class>org.jboss.portal.faces.loader.FacesPortlet</portlet-class>
+ <init-param>
+ <name>default-view</name>
+ <value>/WEB-INF/jsf/index.xhtml</value>
+ </init-param>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
Modified: branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/web.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/web.xml 2007-08-09 12:38:58 UTC (rev 7880)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/resources/portal-search-war/WEB-INF/web.xml 2007-08-09 12:45:50 UTC (rev 7881)
@@ -1,6 +1,80 @@
<?xml version="1.0"?>
-<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
-<web-app>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <!-- MyFaces specific configuration -->
+ <context-param>
+ <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
+ <param-value>true</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- Facelet configuration -->
+ <context-param>
+ <param-name>facelets.DEVELOPMENT</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
+ <param-name>facelets.SKIP_COMMENTS</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!-- JSF configuration -->
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.xhtml</param-value>
+ </context-param>
+ <context-param>
+ <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
+ <param-value>server</param-value>
+ </context-param>
+
+ <!-- The JSF servlet -->
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>org.jboss.portal.faces.loader.FacesLoaderServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
</web-app>
16 years, 9 months
JBoss Portal SVN: r7880 - in branches/JBoss_Portal_Branch_2_6: core-admin and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 08:38:58 -0400 (Thu, 09 Aug 2007)
New Revision: 7880
Modified:
branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
branches/JBoss_Portal_Branch_2_6/build/build.xml
branches/JBoss_Portal_Branch_2_6/core-admin/build.xml
branches/JBoss_Portal_Branch_2_6/core-wsrp/build.xml
Log:
- Ant descriptions typos
- Upgrade from Myfaces 1.1.1 to 1.1.5
Modified: branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2007-08-09 09:00:35 UTC (rev 7879)
+++ branches/JBoss_Portal_Branch_2_6/build/build-thirdparty.xml 2007-08-09 12:38:58 UTC (rev 7880)
@@ -50,7 +50,7 @@
<componentref name="antlr" version="2.7.6.ga"/>
<componentref name="apache-ant" version="1.6.5"/>
<componentref name="jackrabbit" version="1.1.1"/>
- <componentref name="apache-myfaces" version="1.1.1"/>
+ <componentref name="apache-myfaces" version="1.1.5"/>
<componentref name="apache-beanutils" version="1.7.0"/>
<componentref name="apache-codec" version="1.3.0"/>
<componentref name="apache-collections" version="3.1"/>
@@ -58,7 +58,7 @@
<!--<componentref name="apache-directory" version="mixed"/>-->
<componentref name="apache-fileupload" version="1.1.1"/>
<componentref name="apache-httpclient" version="3.0.1"/>
- <componentref name="apache-lang" version="2.0"/>
+ <componentref name="apache-lang" version="2.1"/>
<componentref name="apache-log4j" version="1.2.8"/>
<componentref name="apache-logging" version="1.0.5.SP1-jboss"/>
<componentref name="apache-lucene" version="1.4.3"/>
Modified: branches/JBoss_Portal_Branch_2_6/build/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/build/build.xml 2007-08-09 09:00:35 UTC (rev 7879)
+++ branches/JBoss_Portal_Branch_2_6/build/build.xml 2007-08-09 12:38:58 UTC (rev 7880)
@@ -287,7 +287,7 @@
</target>
<target name="deploy-all"
- description="Undeploy all archives."
+ description="Deploy all archives."
depends="most">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<copy file="../core/output/lib/jboss-portal.sar" todir="${jboss.home}/server/${portal.deploy.dir}" overwrite="true"/>
@@ -304,7 +304,7 @@
</target>
<target name="undeploy-all"
- description="Deploy all archives."
+ description="Undeploy all archives."
depends="init">
<require file="${jboss.home}/server/${portal.deploy.dir}"/>
<delete file="${jboss.home}/server/${portal.deploy.dir}/jboss-portal.sar"/>
Modified: branches/JBoss_Portal_Branch_2_6/core-admin/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-admin/build.xml 2007-08-09 09:00:35 UTC (rev 7879)
+++ branches/JBoss_Portal_Branch_2_6/core-admin/build.xml 2007-08-09 12:38:58 UTC (rev 7880)
@@ -200,6 +200,7 @@
<fileset dir="${commons.el.lib}" includes="commons-el.jar"/>
<fileset dir="${apache.beanutils.lib}" includes="commons-beanutils.jar"/>
<fileset dir="${apache.digester.lib}" includes="commons-digester.jar"/>
+ <fileset dir="${apache.lang.lib}" includes="commons-lang.jar"/>
</copy>
<copy todir="${build.resources}/portal-admin-war">
<fileset dir="${source.bin}/portal-admin-war"/>
Modified: branches/JBoss_Portal_Branch_2_6/core-wsrp/build.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-wsrp/build.xml 2007-08-09 09:00:35 UTC (rev 7879)
+++ branches/JBoss_Portal_Branch_2_6/core-wsrp/build.xml 2007-08-09 12:38:58 UTC (rev 7880)
@@ -212,6 +212,7 @@
<fileset dir="${facelets.facelets.lib}" includes="jsf-facelets.jar"/>
<fileset dir="${el.el.lib}" includes="el-api.jar,el-ri.jar"/>
<fileset dir="${commons.el.lib}" includes="commons-el.jar"/>
+ <fileset dir="${apache.lang.lib}" includes="commons-lang.jar"/>
<fileset dir="${apache.beanutils.lib}" includes="commons-beanutils.jar"/>
<fileset dir="${apache.digester.lib}" includes="commons-digester.jar"/>
</copy>
16 years, 9 months
JBoss Portal SVN: r7879 - trunk/faces/src/main/org/jboss/portal/faces/el.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-09 05:00:35 -0400 (Thu, 09 Aug 2007)
New Revision: 7879
Modified:
trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
Log:
The delegating property resolver should also check on the super-classes to find attributes
Modified: trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java 2007-08-09 08:59:14 UTC (rev 7878)
+++ trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java 2007-08-09 09:00:35 UTC (rev 7879)
@@ -378,6 +378,15 @@
return true;
}
}
+ Class superClass = clazz.getSuperclass();
+ if (superClass != null)
+ {
+ if (resolveAction(superClass, action))
+ {
+ return true;
+ }
+ }
+
return false;
}
16 years, 9 months