JBoss Portal SVN: r7898 - in trunk: core-admin and 11 other directories.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2007-08-10 18:50:33 -0400 (Fri, 10 Aug 2007)
New Revision: 7898
Added:
trunk/core-admin/src/main/org/jboss/portal/test/
trunk/core-admin/src/main/org/jboss/portal/test/core/
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/SimpleTest.java
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/PortalServletContextListener.java
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletContextAttributes.java
trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletPortletViewHandler.java
trunk/core-admin/src/resources/portal-admin-test-sar/
trunk/core-admin/src/resources/portal-admin-test-sar/META-INF/
trunk/core-admin/src/resources/portal-admin-test-sar/META-INF/jboss-beans.xml
trunk/core-admin/src/resources/portal-admin-test-sar/lib/
trunk/core-admin/src/resources/portal-admin-test-war/
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/datasources.xml
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/hibernates.xml
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/jboss-web.xml
trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/web.xmlfragment
trunk/core-admin/src/resources/portal-admin-test-war/portalviewer.jsp
Modified:
trunk/build/build-thirdparty.xml
trunk/core-admin/.classpath
trunk/core-admin/build.xml
Log:
Initial checkin of portal-admin test framework
Modified: trunk/build/build-thirdparty.xml
===================================================================
--- trunk/build/build-thirdparty.xml 2007-08-10 15:00:02 UTC (rev 7897)
+++ trunk/build/build-thirdparty.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -91,12 +91,14 @@
<componentref name="jboss/remoting" version="1.4.3.GA"/>
<componentref name="jboss/serialization" version="1.0.1.GA"/>
<componentref name="jboss/test" version="1.0.0.CR1"/>
+ <componentref name="jboss-jsfunit" version="1.0-snapshot"/>
<componentref name="jflex" version="1.4.0"/>
<componentref name="jwebunit" version="1.2"/>
<componentref name="jcr" version="1.0"/>
<componentref name="jetty" version="6.0"/>
<componentref name="jgroups" version="2.2.8"/>
<componentref name="jsunit" version="2.1"/>
+ <componentref name="jtidy" version="4aug2000r7"/>
<componentref name="junit" version="3.8.1"/>
<componentref name="odmg" version="3.0"/>
<componentref name="oswego-concurrent" version="1.3.4"/>
@@ -111,6 +113,7 @@
<componentref name="sun-opends" version="snapshot"/>
<componentref name="sun-servlet" version="2.4"/>
<componentref name="xdoclet" version="1.2.3"/>
+ <componentref name="xmltask" version="1.15.1"/>
<componentref name="jbpm/jaronly" version="3.1.2"/>
<componentref name="freemarker" version="2.3.9"/>
<componentref name="wutka-dtdparser" version="1.2.1"/>
Modified: trunk/core-admin/.classpath
===================================================================
--- trunk/core-admin/.classpath 2007-08-10 15:00:02 UTC (rev 7897)
+++ trunk/core-admin/.classpath 2007-08-10 22:50:33 UTC (rev 7898)
@@ -21,5 +21,11 @@
<classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/jsp-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss-jsfunit/lib/jsfunit-ant.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss-jsfunit/lib/jsfunit-core.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jakarta-cactus/lib/cactus.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jakarta-cactus/lib/cactus-ant.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/test"/>
<classpathentry kind="output" path="output/classes"/>
</classpath>
Modified: trunk/core-admin/build.xml
===================================================================
--- trunk/core-admin/build.xml 2007-08-10 15:00:02 UTC (rev 7897)
+++ trunk/core-admin/build.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -66,6 +66,7 @@
| Initialize the build system. Must depend on '_buildmagic:init'.
| Other targets should depend on 'init' or things will mysteriously fail.
-->
+ <import file="../testsuite/imports/server-config.xml"/>
<target name="init" unless="init.disable" depends="_buildmagic:init">
</target>
@@ -83,6 +84,8 @@
<property name="jboss-junit-configuration" value=""/>
<property name="junit.formatter.usefile" value="true"/>
+ <property name="test.reports" value="${module.output}/tests"/>
+
<!-- Configure thirdparty libraries -->
&libraries;
@@ -96,6 +99,9 @@
<path refid="sun.servlet.classpath"/>
<path refid="facelets.facelets.classpath"/>
<path refid="el.el.classpath"/>
+ <path refid="jakarta.cactus.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="jboss.jsfunit.classpath"/>
<pathelement location="${source.etc}/sun-jsf/jsf-example.jar"/>
</path>
@@ -140,9 +146,42 @@
<taskdef name="implode"
classname="org.jboss.portal.common.ant.Implode"
classpathref="explode.task.classpath"/>
+ <taskdef name="xmltask"
+ classname="com.oopsconsultancy.xmltask.ant.XmlTask"
+ classpathref="xmltask.xmltask.classpath"/>
+ <taskdef name="jsfunitwar"
+ classname="org.jboss.jsfunit.ant.JSFUnitWarTask">
+ <classpath>
+ <fileset dir="${jboss.jsfunit.lib}"/>
+<!-- <fileset dir="${cargo.lib}"/> -->
+ <fileset dir="${jakarta.cactus.lib}"/>
+ <fileset dir="${aspectj.aspectj.lib}"/>
+ <fileset dir="${nekohtml.nekohtml.lib}"/>
+ <fileset dir="${httpunit.httpunit.lib}"/>
+ <fileset dir="${jtidy.jtidy.lib}"/>
+ <fileset dir="${project.tools}/lib">
+ <include name="*cargo**"/>
+ </fileset>
+ </classpath>
+ </taskdef>
</target>
-
+
+ <path id="portal.task.classpath">
+ <pathelement location="${project.tools}/lib/ant.jar"/>
+ <pathelement location="${project.tools}/lib/explode.jar"/>
+ <pathelement location="${project.tools}/lib/cargo-core-uberjar-0.8.jar"/>
+ </path>
+ <taskdef
+ name="deploy"
+ classname="org.jboss.portal.common.ant.Deploy"
+ classpathref="portal.task.classpath"/>
+ <taskdef
+ name="undeploy"
+ classname="org.jboss.portal.common.ant.Undeploy"
+ classpathref="portal.task.classpath"/>
+
+
<target name="configure-explode">
<path id="explode.task.classpath">
<pathelement location="${project.tools}/lib/explode.jar"/>
@@ -186,7 +225,7 @@
<!-- portal-core-admin-lib.jar -->
<jar jarfile="${build.lib}/portal-core-admin-lib.jar">
- <fileset dir="${build.classes}"/>
+ <fileset dir="${build.classes}" excludes="org/jboss/portal/test/**"/>
</jar>
<!-- portal-admin.war -->
@@ -279,7 +318,91 @@
<delete file="${jboss.home}/server/${portal.deploy.dir}/portal-admin.sar"/>
</target>
- <target name="package-tests"/>
+ <target name="package-tests" depends="init, clean-tests">
+
+ <!-- create the jar to contain the test files -->
+ <jar jarfile="${build.lib}/portal-core-admin-test-lib.jar">
+ <fileset dir="${build.classes}" includes="org/jboss/portal/test/**"/>
+ </jar>
+
+ <!-- portal-admin-test-temp.war -->
+ <copy todir="${build.resources}/portal-admin-test-temp.war">
+ <fileset dir="${build.resources}/portal-admin-war"/>
+ <fileset dir="${build.resources}/portal-admin-test-war" excludes="**/*.xmlfragment"/>
+ </copy>
+
+ <!-- jsfunitwar _cannot_ be called later on since cargo gets confused on the more complicated war -->
+ <jsfunitwar srcfile="${build.resources}/portal-admin-test-temp.war"
+ destfile="${build.resources}/portal-admin-test.war">
+ <TestRunner/>
+ </jsfunitwar>
+
+ <!-- Use xmltask to change the specifics of the xml descriptors that are different for the tests -->
+ <xmltask source="${build.resources}/portal-admin-test.war/WEB-INF/faces-config.xml"
+ dest="${build.resources}/portal-admin-test.war/WEB-INF/faces-config.xml">
+ <replace path="//*[local-name()='faces-config']/:application/:view-handler/text()"
+ withText="org.jboss.portal.test.core.admin.bootstrap.ServletPortletViewHandler"/>
+ </xmltask>
+ <xmltask source="${build.resources}/portal-admin-test.war/WEB-INF/web.xml"
+ dest="${build.resources}/portal-admin-test.war/WEB-INF/web.xml">
+ <insert path="//*[local-name()='web-app']"
+ file="${build.resources}/portal-admin-test-war/WEB-INF/web.xmlfragment"/>
+ <replace path="//*[local-name()='web-app']/:servlet[:servlet-name/text() = 'Faces Servlet']/:servlet-class/text()"
+ withText="javax.faces.webapp.FacesServlet"/>
+ </xmltask>
+
+ <copy todir="${build.resources}/portal-admin-test.sar">
+ <fileset dir="${build.resources}/portal-admin.sar" excludes="portal-admin.war**"/>
+ <fileset dir="${build.resources}" includes="portal-admin-test.war/**"/>
+ <fileset dir="${build.resources}/portal-admin-test-sar"/>
+ </copy>
+
+ <copy todir="${build.resources}/portal-admin-test.sar/portal-admin-test.war/WEB-INF/lib2">
+ <fileset dir="${build.lib}" includes="portal-core-admin-test-lib.jar"/>
+ <fileset dir="${jboss.portal-wsrp.lib}" includes="portal-wsrp-lib.jar"/>
+ <fileset dir="${jboss.portal-test.lib}" includes="portal-test-lib.jar"/>
+ </copy>
+
+ <!-- we want to use the lib directory since we are not using the custom portal lib2 directory -->
+ <copy todir="${build.resources}/portal-admin-test.sar/portal-admin-test.war/WEB-INF/lib">
+ <fileset dir="${build.resources}/portal-admin-test.sar/portal-admin-test.war/WEB-INF/lib2"/>
+ </copy>
+ <!-- delete the lib2 directory since we don't use it for the tests -->
+ <delete dir="${build.resources}/portal-admin-test.sar/portal-admin-test.war/WEB-INF/lib2"/>
+
+ <implode
+ dir="${build.resources}/portal-admin-test.sar"
+ tofile="${build.lib}/portal-admin-test.sar"/>
+
+ </target>
+
+ <target name="clean-tests" description="cleans the output from the package-test command">
+ <delete dir="${build.resources}/portal-admin-test.sar" failonerror="false"/>
+ <delete dir="${build.resources}/portal-admin-test-temp.war" failonerror="false"/>
+ <delete dir="${build.resources}/portal-admin-test.war" failonerror="false"/>
+ <delete dir="${build.lib}/portal-admin-test.sar" failonerror="false"/>
+ </target>
+
+ <target name="tests" depends="init" description="Runs the portal-admin tests">
+ <mkdir dir="${build.reports}"/>
+ <mkdir dir="${test.reports}"/>
+ <deploy file="${jboss.portal-core.lib}/jboss-portal.sar" config="default"/>
+ <deploy file="${build.lib}/portal-admin-test.sar" config="default"/>
+ <junit printsummary="true" haltonerror="false" fork="true">
+ <jvmarg value="-Dcactus.contextURL=http://localhost:8080/portal-admin-test"/>
+ <classpath>
+ <fileset dir="${build.resources}/portal-admin-test.sar/portal-admin-test.war/WEB-INF/lib"/>
+ <fileset dir="${apache.httpclient.lib}"/>
+ <fileset dir="${apache.logging.lib}"/>
+ <fileset dir="${apache.codec.lib}"/>
+ </classpath>
+ <formatter type="xml"/>
+ <test todir="${test.reports}" name="org.jboss.portal.test.core.admin.SimpleTest"/>
+ </junit>
+ <undeploy file="${jboss-portal-core.lib}/jboss-portal.sar" config="default"/>
+ <undeploy file="${build.resources}/portal-admin-test.sar" config="default"/>
+ </target>
+
<!--
Added: trunk/core-admin/src/main/org/jboss/portal/test/core/admin/SimpleTest.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/test/core/admin/SimpleTest.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/test/core/admin/SimpleTest.java 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,35 @@
+package org.jboss.portal.test.core.admin;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebRequest;
+import org.apache.cactus.client.authentication.BasicAuthentication;
+import org.jboss.jsfunit.facade.ClientFacade;
+import org.jboss.jsfunit.facade.ServerFacade;
+import org.xml.sax.SAXException;
+
+public class SimpleTest extends ServletTestCase {
+
+ private ClientFacade clientFacade;
+
+ public void beginSomething (WebRequest theRequest)
+ {
+ theRequest.setAuthentication(new BasicAuthentication("admin", "admin"));
+ }
+
+
+
+ public void setUp() throws MalformedURLException, IOException, SAXException
+ {
+ System.out.println("Starting setup");
+ }
+
+ public void testSomething() throws IOException, SAXException
+ {
+ this.clientFacade = new ClientFacade ("/portalviewer.jsp?view=/WEB-INF/jsf/objects.faces", "admin", "admin");
+ ServerFacade serverFacade = new ServerFacade(clientFacade);
+ }
+
+}
Added: trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/PortalServletContextListener.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/PortalServletContextListener.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/PortalServletContextListener.java 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.test.core.admin.bootstrap;
+
+import java.net.URL;
+
+import javax.faces.context.ExternalContext;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer;
+import org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl;
+import org.jboss.portal.test.framework.TestRuntimeContext;
+import org.jboss.portal.test.framework.embedded.DataSourceSupport;
+import org.jboss.portal.test.framework.embedded.HibernateSupport;
+
+public class PortalServletContextListener implements ServletContextListener{
+
+
+ public void contextInitialized(ServletContextEvent event) {
+ try{
+
+ // Create wrapper that configures
+ ServletContext servletContext = event.getServletContext();
+ ServletContextAttributes attrs = new ServletContextAttributes(servletContext);
+
+ // Configure MC
+ TestRuntimeContext runtimeContext = new TestRuntimeContext("META-INF/jboss-beans.xml");
+ runtimeContext.addBean("ServletContextAttributes", attrs);
+
+ PersistentPortalObjectContainer objectContainer = new PersistentPortalObjectContainer();
+ objectContainer.setSessionFactoryJNDIName("java:/portal/PortalObjectSessionFactory");
+ objectContainer.setAuthorizationDomainRegistry(new JBossAuthorizationDomainRegistryImpl());
+ objectContainer.start();
+ runtimeContext.addBean("PortalObjectContainer", objectContainer);
+
+ URL configsURL = Thread.currentThread().getContextClassLoader().getResource("datasources.xml");
+ DataSourceSupport.Config[] dataSourceConfigParameter = DataSourceSupport.Config.fromXML(configsURL);
+
+ runtimeContext.addBean("DataSourceConfig", dataSourceConfigParameter[0]);
+ runtimeContext.addBean("HibernateConfig", HibernateSupport.getConfig(dataSourceConfigParameter[0].getName()));
+
+ runtimeContext.start();
+ } catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+
+ public void contextDestroyed(ServletContextEvent event) {
+ // do nothing right now
+ }
+
+}
\ No newline at end of file
Added: trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletContextAttributes.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletContextAttributes.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletContextAttributes.java 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,46 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.test.core.admin.bootstrap;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+public class ServletContextAttributes {
+ private ServletContext context;
+ public ServletContextAttributes(ServletContext context)
+ {
+ this.context = context;
+ }
+ public void setAttributes(Map attrs)
+ {
+ for (Iterator i = attrs.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ Object value = entry.getValue();
+ context.setAttribute(name, value);
+ }
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletPortletViewHandler.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletPortletViewHandler.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/test/core/admin/bootstrap/ServletPortletViewHandler.java 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2007, 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.test.core.admin.bootstrap;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import javax.faces.FacesException;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+
+import com.sun.facelets.FaceletViewHandler;
+
+public class ServletPortletViewHandler extends FaceletViewHandler {
+
+ public ServletPortletViewHandler(ViewHandler viewHandler) {
+ super(viewHandler);
+ }
+
+ public String getActionURL(FacesContext context, String viewId) {
+ String actionURL = super.getActionURL(context, viewId);
+
+ // if the actionURL is trying to access an internal resource then
+ // we need to make it use the portalview jsp page.
+ // NOTE: this viewhandler should only be used for testing as it can access
+ // internal resources in WEB-INF
+ if (actionURL.contains("WEB-INF") && !actionURL.contains("portalviewer"))
+ {
+ String portalviewUrl = "/portalviewer.jsp?view=";
+
+ //for some reason // will sometimes appear in the actionurl which can cause problems
+ actionURL.replace("//", "/");
+
+ int endofWebappContext = actionURL.indexOf("/", 1);
+ String webappContext = actionURL.substring(0, endofWebappContext);
+ String internalPage = actionURL.substring(endofWebappContext);
+
+ System.out.println ( "NEW ACTIONURL : " + webappContext + portalviewUrl + internalPage);
+ actionURL = webappContext +portalviewUrl + internalPage;
+ }
+
+ return actionURL;
+ }
+}
Added: trunk/core-admin/src/resources/portal-admin-test-sar/META-INF/jboss-beans.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-sar/META-INF/jboss-beans.xml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-sar/META-INF/jboss-beans.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="DataSourceConfig"
+ class="org.jboss.portal.test.framework.embedded.DataSourceSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory" />
+ <parameter>DataSourceConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="HibernateConfig"
+ class="org.jboss.portal.test.framework.embedded.HibernateSupport$Config">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory" />
+ <parameter>HibernateConfig</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="JNDISupport"
+ class="org.jboss.portal.test.framework.embedded.JNDISupport" />
+
+ <bean name="TransactionManagerSupport"
+ class="org.jboss.portal.test.framework.embedded.TransactionManagerSupport" />
+
+ <bean name="ConnectionManagerSupport"
+ class="org.jboss.portal.test.framework.embedded.ConnectionManagerSupport">
+ <property name="transactionManager">
+ <inject bean="TransactionManagerSupport"
+ property="transactionManager" />
+ </property>
+ </bean>
+
+ <bean name="DataSourceSupport"
+ class="org.jboss.portal.test.framework.embedded.DataSourceSupport">
+ <property name="transactionManager">
+ <inject bean="TransactionManagerSupport"
+ property="transactionManager" />
+ </property>
+ <property name="connectionManagerReference">
+ <inject bean="ConnectionManagerSupport"
+ property="connectionManagerReference" />
+ </property>
+ <property name="config">
+ <inject bean="DataSourceConfig" />
+ </property>
+ </bean>
+
+ <bean name="InstanceHibernateSupport"
+ class="org.jboss.portal.test.framework.embedded.HibernateSupport">
+ <property name="config">
+ <inject bean="HibernateConfig" />
+ </property>
+ <property name="mappings">
+ <list elementClass="java.lang.String">
+ <value>conf/hibernate/instance/domain.hbm.xml</value>
+ </list>
+ </property>
+ <property name="jNDIName">
+ java:/portal/InstanceSessionFactory
+ </property>
+ </bean>
+
+ <bean name="PortalObjectContainer"
+ class="org.jboss.portal.core.impl.model.portal.PersistentPortalObjectContainer">
+ <property name="sessionFactoryJNDIName">
+ java:/portal/InstanceSessionFactory
+ </property>
+ <property name="authorizationDomainRegistry">
+ <inject bean="AuthorizationDomainRegistry" />
+ </property>
+ <property name="portalAuthorizationManagerFactory">
+ <inject bean="AuthorizationManagerFactory" />
+ </property>
+ </bean>
+
+ <bean name="ServletContextAttributes"
+ class="org.jboss.portal.test.core.admin.bootstrap.ServletContextAttributes">
+ <constructor factoryMethod="getBean">
+ <factory bean="BeanFactory" />
+ <parameter>ServletContextAttributes</parameter>
+ </constructor>
+ <property name="attributes">
+ <map keyClass="java.lang.String">
+ <entry>
+ <key>InstanceHibernateSupport</key>
+ <value>
+ <inject bean="InstanceHibernateSupport" />
+ </value>
+ </entry>
+ <entry>
+ <key>PortalObjectContainer</key>
+ <value>
+ <inject bean="PortalObjectContainer" />
+ </value>
+ </entry>
+ </map>
+ </property>
+ </bean>
+
+ <bean name="ContainerContext"
+ class="org.jboss.portal.core.impl.model.instance.persistent.PersistentInstanceContainerContext">
+ <property name="sessionFactoryJNDIName">
+ java:/portal/InstanceSessionFactory
+ </property>
+ <property name="cacheNaturalId">true</property>
+ </bean>
+
+ <bean name="StackFactory"
+ class="org.jboss.portal.common.invocation.EmptyInterceptorStackFactory" />
+
+ <bean name="StateConverter"
+ class="org.jboss.portal.portlet.impl.state.StateConverterV0" />
+
+ <bean name="StateManagementPolicy"
+ class="org.jboss.portal.portlet.impl.state.StateManagementPolicyService" />
+
+ <bean name="PersistenceManager"
+ class="org.jboss.portal.core.impl.portlet.state.PersistentPortletStatePersistenceManager">
+ <property name="sessionFactoryJNDIName">java:/portal/PortletSessionFactory</property>
+ </bean>
+ <bean name="PortletContainer"
+ class="org.jboss.portal.portlet.test.support.PortletInvokerSupport" />
+
+ <bean name="Producer"
+ class="org.jboss.portal.portlet.state.producer.ProducerPortletInvoker">
+ <property name="persistenceManager">
+ <inject bean="PersistenceManager" />
+ </property>
+ <property name="portletInvoker">
+ <inject bean="PortletContainer" />
+ </property>
+ <property name="stateManagementPolicy">
+ <inject bean="StateManagementPolicy" />
+ </property>
+ <property name="stateConverter">
+ <inject bean="StateConverter" />
+ </property>
+ </bean>
+
+ <bean name="InstanceContainer"
+ class="org.jboss.portal.core.impl.model.instance.InstanceContainerImpl">
+ <property name="portletInvoker">
+ <inject bean="Producer" />
+ </property>
+ <property name="containerContext">
+ <inject bean="ContainerContext" />
+ </property>
+ <property name="stackFactory">
+ <inject bean="StackFactory" />
+ </property>
+ </bean>
+
+ <bean name="AuthorizationDomainRegistry"
+ class="org.jboss.portal.security.impl.JBossAuthorizationDomainRegistryImpl" />
+
+ <bean name="AuthorizationManagerFactory"
+ class="org.jboss.portal.security.impl.jacc.JACCPortalAuthorizationManagerFactory">
+ <property name="authorizationDomainRegistry">
+ <inject bean="AuthorizationDomainRegistry" />
+ </property>
+ </bean>
+
+</deployment>
Added: trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/datasources.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/datasources.xml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/datasources.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,60 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<datasources>
+ <!-- The hsqldb datasource -->
+ <datasource>
+ <datasource-name>hsqldb</datasource-name>
+ <connection-url>jdbc:hsqldb:file:test</connection-url>
+ <driver-class>org.hsqldb.jdbcDriver</driver-class>
+ <user-name>sa</user-name>
+ <password></password>
+ </datasource>
+<!--
+ <datasource>
+ <datasource-name>mysql5</datasource-name>
+ <connection-url>jdbc:mysql://localhost:3306/jbossportal?useServerPrepStmts=false&jdbcCompliantTruncation=false</connection-url>
+ <driver-class>com.mysql.jdbc.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>portalpassword</password>
+ </datasource>
+-->
+<!--
+ <datasource>
+ <datasource-name>oracle10g</datasource-name>
+ <connection-url>jdbc:oracle:thin:jbossportal/portalpassword@192.168.0.124:1521:orcl</connection-url>
+ <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
+ <user-name>jbossportal</user-name>
+ <password>portalpassword</password>
+ </datasource>
+-->
+<!--
+ <datasource>
+ <datasource-name>postgresql8</datasource-name>
+ <connection-url>jdbc:postgresql:jbossportal</connection-url>
+ <driver-class>org.postgresql.Driver</driver-class>
+ <user-name>portal</user-name>
+ <password>portalpassword</password>
+ </datasource>
+-->
+</datasources>
Added: trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/hibernates.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/hibernates.xml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/classes/hibernates.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,110 @@
+<configurations>
+ <!-- The default configuration that will apply everywhere -->
+ <configuration>
+ <configuration-name>default</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.show_sql</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.auto_close_session</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.flush_before_completion</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.factory_class</name>
+ <value>org.hibernate.transaction.JTATransactionFactory</value>
+ </property>
+ <property>
+ <name>hibernate.transaction.manager_lookup_class</name>
+ <value>org.hibernate.transaction.JBossTransactionManagerLookup</value>
+ </property>
+ <property>
+ <name>hibernate.cache.provider_class</name>
+ <value>org.hibernate.cache.HashtableCacheProvider</value>
+ </property>
+ <property>
+ <name>hibernate.cache.use_second_level_cache</name>
+ <value>false</value>
+ </property>
+ <property>
+ <name>hibernate.cache.use_query_cache</name>
+ <value>false</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The hsqldb configuration -->
+ <configuration>
+ <configuration-name>hsqldb</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.HSQLDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The oracle 9i configuration -->
+ <configuration>
+ <configuration-name>oracle9i</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The oracle 10g configuration -->
+ <configuration>
+ <configuration-name>oracle10g</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.Oracle9Dialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The sqlserver configuration -->
+ <configuration>
+ <configuration-name>sqlserver</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.SQLServerDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The mysql 4 configuration -->
+ <configuration>
+ <configuration-name>mysql4</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.MySQLInnoDBDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The mysql 5 configuration -->
+ <configuration>
+ <configuration-name>mysql5</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.MySQLInnoDBDialect</value>
+ </property>
+ </properties>
+ </configuration>
+ <!-- The postgresql 8 configuration -->
+ <configuration>
+ <configuration-name>postgresql8</configuration-name>
+ <properties>
+ <property>
+ <name>hibernate.dialect</name>
+ <value>org.hibernate.dialect.PostgreSQLDialect</value>
+ </property>
+ </properties>
+ </configuration>
+</configurations>
\ No newline at end of file
Added: trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/jboss-web.xml (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/jboss-web.xml 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,31 @@
+<?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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<jboss-web>
+ <security-domain>java:jaas/portal</security-domain>
+ <resource-ref>
+ <res-ref-name>jdbc/PortalDS</res-ref-name>
+ <jndi-name>java:PortalDS</jndi-name>
+ </resource-ref>
+</jboss-web>
Added: trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/web.xmlfragment
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/web.xmlfragment (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-war/WEB-INF/web.xmlfragment 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,55 @@
+<!-- this section allows the porlet to be accessed in a servlet context for testing purposes -->
+
+ <filter>
+ <filter-name>TransactionFilter</filter-name>
+ <filter-class>org.jboss.portal.wsrp.servlet.TransactionFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>TransactionFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <welcome-file-list>
+ <welcome-file>portalviewer.faces?view=/WEB-INF/jsf/objects.xhtml</welcome-file>
+ </welcome-file-list>
+
+ <listener>
+ <listener-class>org.jboss.portal.test.core.admin.bootstrap.PortalServletContextListener</listener-class>
+ </listener>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.faces</url-pattern>
+ </servlet-mapping>
+
+
+ <resource-ref>
+ <res-ref-name>jdbc/PortalDS</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ <res-sharing-scope>Shareable</res-sharing-scope>
+ </resource-ref>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>JBoss Portal</realm-name>
+ </login-config>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Authenticated</web-resource-name>
+ <description></description>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>Authenticated</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+
+
+ <security-role>
+ <role-name>Authenticated</role-name>
+ </security-role>
+
+<!-- end testing section -->
Added: trunk/core-admin/src/resources/portal-admin-test-war/portalviewer.jsp
===================================================================
--- trunk/core-admin/src/resources/portal-admin-test-war/portalviewer.jsp (rev 0)
+++ trunk/core-admin/src/resources/portal-admin-test-war/portalviewer.jsp 2007-08-10 22:50:33 UTC (rev 7898)
@@ -0,0 +1,10 @@
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+
+<!-- this jsp is a hack to get around that the portlet's jsf
+ pages exist under the WEB-INF directory, let jsf pages
+ with forms can't normally be access in the WEB-INF directory -->
+
+<% String view = request.getParameter("view");%>
+
+<jsp:forward page="<%= view %>"/>
\ No newline at end of file
16 years, 10 months
JBoss Portal SVN: r7897 - in trunk: core/src/main/org/jboss/portal/core/controller/command/mapper and 2 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-10 11:00:02 -0400 (Fri, 10 Aug 2007)
New Revision: 7897
Added:
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java
trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java
Modified:
trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
Log:
- JBPORTAL-1612: Let the user specify a redirection on the signout URL mapping
- Sign Out, URL factory now specify the redirection location
- JBPORTAL-1590: Fix logging
Modified: trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-08-10 14:56:56 UTC (rev 7896)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-08-10 15:00:02 UTC (rev 7897)
@@ -43,7 +43,7 @@
/** . */
private String location;
-
+
public SignOutCommand()
{
this(null);
@@ -58,6 +58,11 @@
{
return info;
}
+
+ public String getLocation()
+ {
+ return location;
+ }
public ControllerResponse execute() throws ControllerException
{
Copied: trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java (from rev 7895, branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java 2007-08-10 15:00:02 UTC (rev 7897)
@@ -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.controller.command.mapper;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface SignOutCommandFactory
+{
+
+}
+
Copied: trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java (from rev 7895, branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java 2007-08-10 15:00:02 UTC (rev 7897)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.controller.command.mapper;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.SignOutCommand;
+import org.jboss.portal.server.ServerInvocation;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SignOutCommandFactoryService extends AbstractCommandFactory implements SignOutCommandFactory
+{
+
+ public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host,
+ String contextPath, String requestPath)
+ {
+ String location = null;
+ ParameterMap parameterMap = controllerContext.getServerInvocation().getServerContext().getQueryParameterMap();
+ if (parameterMap != null)
+ {
+ try
+ {
+ if (parameterMap.get("location") != null)
+ {
+ location = URLDecoder.decode(((String[]) parameterMap.get("location"))[0], "UTF-8");
+ }
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore
+ }
+ }
+
+ if (location == null)
+ {
+ return new SignOutCommand();
+ }
+ else
+ {
+ return new SignOutCommand(location);
+ }
+ }
+
+}
+
Copied: trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java (from rev 7895, branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java)
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java (rev 0)
+++ trunk/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java 2007-08-10 15:00:02 UTC (rev 7897)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * 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.controller.command.mapper;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.SignOutCommand;
+import org.jboss.portal.server.AbstractServerURL;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerURL;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SignOutURLFactory extends URLFactoryDelegate
+{
+
+ /** . */
+ private String path;
+
+ public ServerURL doMapping(ControllerContext controllerContext, ServerInvocation invocation, ControllerCommand cmd)
+ {
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No null command accepted");
+ }
+ if (cmd instanceof SignOutCommand)
+ {
+ SignOutCommand signOutCommand = (SignOutCommand) cmd;
+
+ //
+ AbstractServerURL asu = new AbstractServerURL();
+ asu.setPortalRequestPath(path);
+ String location = signOutCommand.getLocation();
+ if (location != null)
+ {
+ try
+ {
+ asu.setParameterValue("location", URLEncoder.encode(location, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore
+ }
+ }
+ return asu;
+ }
+ return null;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+}
+
Modified: trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-08-10 14:56:56 UTC (rev 7896)
+++ trunk/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-08-10 15:00:02 UTC (rev 7897)
@@ -775,12 +775,11 @@
proxy-type="attribute">portal:commandFactory=PortalObject</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.command.mapper.SimpleCommandFactory"
+ code="org.jboss.portal.core.controller.command.mapper.SignOutCommandFactoryService"
name="portal:commandFactory=SignOut"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <attribute name="CommandClassName">org.jboss.portal.core.controller.command.SignOutCommand</attribute>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
@@ -880,13 +879,12 @@
proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Default</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.command.mapper.SimpleURLFactory"
+ code="org.jboss.portal.core.controller.command.mapper.SignOutURLFactory"
name="portal:urlFactory=SignOut"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="Path">/signout</attribute>
- <attribute name="ClassNames">org.jboss.portal.core.controller.command.SignOutCommand</attribute>
<depends
optional-attribute-name="Factory"
proxy-type="attribute">portal:urlFactory=Delegating</depends>
Modified: trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
===================================================================
--- trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-08-10 14:56:56 UTC (rev 7896)
+++ trunk/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-08-10 15:00:02 UTC (rev 7897)
@@ -226,7 +226,7 @@
//
if (trace)
{
- log.trace("hasPermission:uri=" + permission.getURI() + "::action=" + permission.getType() + "::type=" + permission.getType());
+ log.trace("hasPermission:name=" + permission.getName() + "uri=" + permission.getURI() + "::actions=" + permission.getActions() + "::type=" + permission.getType());
}
//
16 years, 10 months
JBoss Portal SVN: r7896 - branches/JBoss_Portal_Branch_2_6/security/src/main/org/jboss/portal/security/impl/jacc.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-10 10:56:56 -0400 (Fri, 10 Aug 2007)
New Revision: 7896
Modified:
branches/JBoss_Portal_Branch_2_6/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
Log:
JBPORTAL-1590: Fix logging
Modified: branches/JBoss_Portal_Branch_2_6/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-08-10 14:50:35 UTC (rev 7895)
+++ branches/JBoss_Portal_Branch_2_6/security/src/main/org/jboss/portal/security/impl/jacc/JACCPortalAuthorizationManager.java 2007-08-10 14:56:56 UTC (rev 7896)
@@ -226,7 +226,7 @@
//
if (trace)
{
- log.trace("hasPermission:uri=" + permission.getURI() + "::action=" + permission.getType() + "::type=" + permission.getType());
+ log.trace("hasPermission:name=" + permission.getName() + "uri=" + permission.getURI() + "::actions=" + permission.getActions() + "::type=" + permission.getType());
}
//
16 years, 10 months
JBoss Portal SVN: r7895 - in branches/JBoss_Portal_Branch_2_6/core/src: main/org/jboss/portal/core/controller/command/mapper and 1 other directories.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-10 10:50:35 -0400 (Fri, 10 Aug 2007)
New Revision: 7895
Added:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java
Modified:
branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1612: Let the user specify a redirection on the signout URL mapping
Sign Out, URL factory now specify the redirection location
Modified: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-08-10 13:07:59 UTC (rev 7894)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/SignOutCommand.java 2007-08-10 14:50:35 UTC (rev 7895)
@@ -43,7 +43,7 @@
/** . */
private String location;
-
+
public SignOutCommand()
{
this(null);
@@ -58,6 +58,11 @@
{
return info;
}
+
+ public String getLocation()
+ {
+ return location;
+ }
public ControllerResponse execute() throws ControllerException
{
Added: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactory.java 2007-08-10 14:50:35 UTC (rev 7895)
@@ -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.controller.command.mapper;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public interface SignOutCommandFactory
+{
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutCommandFactoryService.java 2007-08-10 14:50:35 UTC (rev 7895)
@@ -0,0 +1,72 @@
+/******************************************************************************
+ * 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.controller.command.mapper;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+
+import org.jboss.portal.common.util.ParameterMap;
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.SignOutCommand;
+import org.jboss.portal.server.ServerInvocation;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SignOutCommandFactoryService extends AbstractCommandFactory implements SignOutCommandFactory
+{
+
+ public ControllerCommand doMapping(ControllerContext controllerContext, ServerInvocation invocation, String host,
+ String contextPath, String requestPath)
+ {
+ String location = null;
+ ParameterMap parameterMap = controllerContext.getServerInvocation().getServerContext().getQueryParameterMap();
+ if (parameterMap != null)
+ {
+ try
+ {
+ if (parameterMap.get("location") != null)
+ {
+ location = URLDecoder.decode(((String[]) parameterMap.get("location"))[0], "UTF-8");
+ }
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore
+ }
+ }
+
+ if (location == null)
+ {
+ return new SignOutCommand();
+ }
+ else
+ {
+ return new SignOutCommand(location);
+ }
+ }
+
+}
+
Added: branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/core/src/main/org/jboss/portal/core/controller/command/mapper/SignOutURLFactory.java 2007-08-10 14:50:35 UTC (rev 7895)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * 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.controller.command.mapper;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.jboss.portal.core.controller.ControllerCommand;
+import org.jboss.portal.core.controller.ControllerContext;
+import org.jboss.portal.core.controller.command.SignOutCommand;
+import org.jboss.portal.server.AbstractServerURL;
+import org.jboss.portal.server.ServerInvocation;
+import org.jboss.portal.server.ServerURL;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class SignOutURLFactory extends URLFactoryDelegate
+{
+
+ /** . */
+ private String path;
+
+ public ServerURL doMapping(ControllerContext controllerContext, ServerInvocation invocation, ControllerCommand cmd)
+ {
+ if (cmd == null)
+ {
+ throw new IllegalArgumentException("No null command accepted");
+ }
+ if (cmd instanceof SignOutCommand)
+ {
+ SignOutCommand signOutCommand = (SignOutCommand) cmd;
+
+ //
+ AbstractServerURL asu = new AbstractServerURL();
+ asu.setPortalRequestPath(path);
+ String location = signOutCommand.getLocation();
+ if (location != null)
+ {
+ try
+ {
+ asu.setParameterValue("location", URLEncoder.encode(location, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore
+ }
+ }
+ return asu;
+ }
+ return null;
+ }
+
+ public String getPath()
+ {
+ return path;
+ }
+
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+}
+
Modified: branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-08-10 13:07:59 UTC (rev 7894)
+++ branches/JBoss_Portal_Branch_2_6/core/src/resources/portal-core-sar/META-INF/jboss-service.xml 2007-08-10 14:50:35 UTC (rev 7895)
@@ -775,12 +775,11 @@
proxy-type="attribute">portal:commandFactory=PortalObject</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.command.mapper.SimpleCommandFactory"
+ code="org.jboss.portal.core.controller.command.mapper.SignOutCommandFactoryService"
name="portal:commandFactory=SignOut"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
- <attribute name="CommandClassName">org.jboss.portal.core.controller.command.SignOutCommand</attribute>
</mbean>
<mbean
code="org.jboss.portal.core.controller.command.mapper.CommandFactoryDelegate"
@@ -880,13 +879,12 @@
proxy-type="attribute">portal:service=PortalObjectPathMapper,type=Default</depends>
</mbean>
<mbean
- code="org.jboss.portal.core.controller.command.mapper.SimpleURLFactory"
+ code="org.jboss.portal.core.controller.command.mapper.SignOutURLFactory"
name="portal:urlFactory=SignOut"
xmbean-dd=""
xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="Path">/signout</attribute>
- <attribute name="ClassNames">org.jboss.portal.core.controller.command.SignOutCommand</attribute>
<depends
optional-attribute-name="Factory"
proxy-type="attribute">portal:urlFactory=Delegating</depends>
16 years, 10 months
JBoss Portal SVN: r7894 - 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-10 09:07:59 -0400 (Fri, 10 Aug 2007)
New Revision: 7894
Added:
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java
Removed:
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/hibernate/
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/test/LuceneQueryTest.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java
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/test/cms/commands/TestSearch.java
branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
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/src/main/org/jboss/portal/core/search/ui/SearchBean.java
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/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/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/StandardQueryConverter.java
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/lucene/LuceneQuery.java
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/TermQuery.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/DummyFederatedSearch.java
branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java
Log:
- Reverted back to have default support for Lucene (and fallback to simple query objects). It allows for end-to-end support on Lucene without interfering.
Modified: branches/JBoss_Portal_Branch_2_6/cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/.classpath 2007-08-10 13:07:59 UTC (rev 7894)
@@ -43,5 +43,6 @@
<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="lib" path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -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;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
/**
* Factory to create commands for the cms service.
@@ -85,5 +85,5 @@
Command createGetArchiveCommand(String sRootPath, String sLanguage);
- Command createSearchCommand(Query query);
+ Command createSearchCommand(JCRQuery query);
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -54,6 +54,7 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.model.Folder;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
@@ -180,7 +181,7 @@
return new GetArchiveCommand(sRootPath, sLanguage);
}
- public Command createSearchCommand(Query query)
+ public Command createSearchCommand(JCRQuery query)
{
return new SearchCommand(query);
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/SearchCommand.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -51,9 +51,9 @@
private static final long serialVersionUID = 2614067614144410297L;
- private Query query;
+ private JCRQuery query;
- public SearchCommand(Query query)
+ public SearchCommand(JCRQuery query)
{
this.query = query;
}
@@ -70,31 +70,24 @@
{
queryManager = workspace.getQueryManager();
- StandardQueryConverter standardConverter = new StandardQueryConverter();
- query = standardConverter.convert(query);
-
- QueryConverter converter = new JCRQueryConverter();
- if (query != null)
+ queryString = query.getJcrQuery();
+
+ if (!"".equals(queryString) && query != null)
{
- queryString = ((JCRQuery) converter.convert(query)).getJcrQuery();
+ javax.jcr.query.Query jcrQuery = queryManager.createQuery(queryString, javax.jcr.query.Query.XPATH);
+ QueryResult queryResult = jcrQuery.execute();
+ NodeIterator nodeIterator = queryResult.getNodes();
- if (!"".equals(queryString) && query != null)
+ while (nodeIterator.hasNext())
{
- 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);
- }
+ 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);
}
}
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/search/CMSFederatedSearch.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -30,7 +30,10 @@
import org.jboss.portal.cms.model.File;
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
import org.jboss.portal.search.result.ResultSet;
/**
@@ -41,12 +44,14 @@
{
private CMS cms;
private String urlPrefix;
+ private JCRQueryConverter queryConverter;
public CMSFederatedSearch(String id)
{
setId(id);
setDisplayName(new LocalizedString("Content Management System"));
this.urlPrefix = "portal/content";
+ this.queryConverter = new JCRQueryConverter();
}
public void setCMS(CMS cms)
@@ -56,7 +61,7 @@
public ResultSet search(Query query)
{
- Command searchCommand = cms.getCommandFactory().createSearchCommand(query);
+ Command searchCommand = cms.getCommandFactory().createSearchCommand((JCRQuery)query);
List files = (List)cms.execute(searchCommand);
ResultSet results = new ResultSet(this);
@@ -69,5 +74,9 @@
return results;
}
-
+ public QueryConverter getQueryConverter()
+ {
+ return queryConverter;
+ }
+
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/test/cms/commands/TestSearch.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -29,8 +29,10 @@
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.Command;
import org.jboss.portal.cms.model.File;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
/**
@@ -51,8 +53,11 @@
/** Tests retrieval of the version labeled LIVE. */
public void testFileGet() throws CMSException
{
- Query query = new QueryImpl("risks");
- Command searchCMD = service.getCommandFactory().createSearchCommand(query);
+ FederatedQuery query = new FederatedQuery("risks");
+
+ JCRQueryConverter converter = new JCRQueryConverter();
+
+ Command searchCMD = service.getCommandFactory().createSearchCommand((JCRQuery)converter.convert(query));
List list = (List)service.execute(searchCMD);
File file = (File)list.get(0);
Modified: branches/JBoss_Portal_Branch_2_6/core-cms/.classpath
===================================================================
--- branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/.classpath 2007-08-10 13:07:59 UTC (rev 7894)
@@ -24,5 +24,6 @@
<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="lib" path="/thirdparty/apache-lucene/lib/lucene.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/main/org/jboss/portal/core/cms/ui/admin/CMSAdminPortlet.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -71,8 +71,10 @@
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.impl.jcr.JCRQuery;
+import org.jboss.portal.search.impl.jcr.JCRQueryConverter;
import org.jboss.portal.security.PortalPermission;
import org.jboss.portal.server.request.URLContext;
import org.jboss.portal.server.request.URLFormat;
@@ -309,11 +311,14 @@
rRes.setContentType("text/html");
String textQuery = rReq.getParameter("search");
- Query query = new QueryImpl(textQuery);
+ FederatedQuery query = new FederatedQuery(textQuery);
+
+ JCRQueryConverter converter = new JCRQueryConverter();
+
List files;
try
{
- Command searchCommand = CMSService.getCommandFactory().createSearchCommand(query);
+ Command searchCommand = CMSService.getCommandFactory().createSearchCommand((JCRQuery)converter.convert(query));
files = (List)CMSService.execute(searchCommand);
}
catch (CMSException e)
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/core-search/src/main/org/jboss/portal/core/search/ui/SearchBean.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -33,12 +33,12 @@
import javax.portlet.PortletContext;
import org.jboss.portal.core.search.service.SearchResultURLFactory;
+import org.jboss.portal.search.FederatedQuery;
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;
@@ -138,10 +138,10 @@
public void search()
{
List results = null;
- Query query;
+ FederatedQuery query;
try
{
- query = new QueryImpl(textString);
+ query = new FederatedQuery(textString);
results = searchService.search(query, selectedFederatedSearchers);
}
catch (SearchingException e)
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedIndexer.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.search;
-import java.util.Locale;
-
import org.jboss.portal.common.i18n.LocalizedString;
import org.jboss.portal.search.federation.Info;
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedQuery.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -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;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.ParseException;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.search.Query;
+import org.jboss.logging.Logger;
+import org.jboss.portal.search.impl.lucene.LuceneQuery;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class FederatedQuery
+{
+
+ private Logger logger = Logger.getLogger(LuceneQuery.class);
+
+ private Query luceneQuery;
+
+ public FederatedQuery(Query luceneQuery)
+ {
+ this.luceneQuery = luceneQuery;
+ }
+
+ public FederatedQuery(String queryString)
+ {
+ try
+ {
+ luceneQuery = QueryParser.parse(queryString, "all" , new StandardAnalyzer());
+ }
+ catch (ParseException e)
+ {
+ logger.debug("Cannot parse query: " + queryString);
+ }
+ }
+
+ public Query getLuceneQuery()
+ {
+ return luceneQuery;
+ }
+
+}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/FederatedSearcher.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -46,6 +46,12 @@
* @return String
*/
public LocalizedString getDisplayName();
+
+ /**
+ * Returns the query converter to apply on the Query
+ * @return
+ */
+ public QueryConverter getQueryConverter();
/**
* From the query object this method is responsible to return the
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/QueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -30,7 +30,7 @@
public interface QueryConverter
{
- public Query convert(Query query) throws QueryConversionException;
+ public Query convert(FederatedQuery query) throws QueryConversionException;
}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/SimpleQuery.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -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.search;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class SimpleQuery implements Query
+{
+
+}
+
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/SearchFederation.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -24,6 +24,7 @@
import java.util.List;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.FederatedSearcher;
import org.jboss.portal.search.SearchingException;
@@ -42,8 +43,8 @@
public FederatedSearcher getFederatedSearcher(String id);
- public List search(Query query) throws SearchingException;
+ public List search(FederatedQuery query) throws SearchingException;
- public List search(Query query, List searchers) throws SearchingException;
+ public List search(FederatedQuery query, List searchers) throws SearchingException;
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/federation/impl/SearchFederationService.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -30,10 +30,13 @@
import java.util.Map;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jboss.portal.search.FederatedQuery;
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.federation.SearchFederation;
+import org.jboss.portal.search.result.ResultSet;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -90,33 +93,54 @@
return (FederatedSearcher)registry.get(id);
}
- public List search(Query query) throws SearchingException
+ public List search(FederatedQuery query) throws SearchingException
{
List results = new ArrayList();
Iterator it = registry.values().iterator();
while (it.hasNext())
{
- FederatedSearcher federated = (FederatedSearcher)it.next();
- results.add(federated.search(query));
+ FederatedSearcher searcher = (FederatedSearcher)it.next();
+ try
+ {
+ results.add(search(query, searcher));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
}
return results;
}
- public List search(Query query, List searchers) throws SearchingException
+ public List search(FederatedQuery query, List searchers) throws SearchingException
{
List results = new ArrayList();
Iterator it = searchers.iterator();
while (it.hasNext())
{
String federatedId = (String)it.next();
- FederatedSearcher federated = getFederatedSearcher(federatedId);
- if (federated == null)
+ FederatedSearcher searcher = getFederatedSearcher(federatedId);
+ if (searcher == null)
{
throw new SearchingException("Cannot find searcher: " + federatedId);
}
- results.add(federated.search(query));
+ try
+ {
+ results.add(search(query, searcher));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
}
return results;
}
+ private ResultSet search(FederatedQuery query, FederatedSearcher searcher) throws QueryConversionException, SearchingException
+ {
+ Query convertedQuery = null;
+ convertedQuery = searcher.getQueryConverter().convert(query);
+ return searcher.search(convertedQuery);
+ }
+
}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/identity/UserSearcher.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Iterator;
-import java.util.Locale;
import java.util.Map;
import javax.naming.InitialContext;
@@ -35,12 +34,12 @@
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.QueryConverter;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+import org.jboss.portal.search.impl.SimpleQueryConverter;
import org.jboss.portal.search.impl.StandardQueryConverter;
import org.jboss.portal.search.query.BooleanClause;
import org.jboss.portal.search.query.BooleanQuery;
@@ -50,7 +49,6 @@
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>
@@ -80,6 +78,8 @@
public ResultSet search(Query query) throws SearchingException
{
ResultSet resultSet = new ResultSet(this);
+
+ /*
StandardQueryConverter queryConverter = new StandardQueryConverter();
try
@@ -90,6 +90,9 @@
{
throw new SearchingException("An error occured while searching", e);
}
+ */
+ search(query, resultSet);
+
return resultSet;
}
@@ -145,6 +148,12 @@
}
}
+ public QueryConverter getQueryConverter()
+ {
+ return new SimpleQueryConverter();
+ }
+
+
}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedIndexer.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -34,11 +34,11 @@
public abstract class AbstractFederatedIndexer extends AbstractJBossService implements FederatedIndexer
{
- private String id;
+ protected String id;
- private LocalizedString displayName;
+ protected LocalizedString displayName;
- private Info info;
+ protected Info info;
public LocalizedString getDisplayName()
{
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractFederatedSearcher.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -26,6 +26,7 @@
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.QueryConverter;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.result.ResultSet;
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/AbstractQueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,13 +22,10 @@
******************************************************************************/
package org.jboss.portal.search.impl;
-import org.jboss.logging.Logger;
+import org.jboss.portal.search.FederatedQuery;
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>
@@ -37,29 +34,34 @@
public abstract class AbstractQueryConverter implements QueryConverter
{
- public Query convert(Query query) throws QueryConversionException
+ public Query convert(FederatedQuery query) throws QueryConversionException
{
- if (query instanceof TermQuery)
+ org.apache.lucene.search.Query luceneQuery = query.getLuceneQuery();
+ if (luceneQuery == null)
{
- return convertTermQuery((TermQuery)query);
+ return null;
}
- else if (query instanceof BooleanQuery)
+ return convert(luceneQuery);
+
+ }
+
+ public Query convert(org.apache.lucene.search.Query luceneQuery) throws QueryConversionException
+ {
+ if (luceneQuery instanceof org.apache.lucene.search.TermQuery)
{
- return convertBooleanQuery((BooleanQuery)query);
+ return convertTermQuery((org.apache.lucene.search.TermQuery)luceneQuery);
}
- else if (query instanceof QueryImpl)
+ else if (luceneQuery instanceof org.apache.lucene.search.BooleanQuery)
{
- StandardQueryConverter converter = new StandardQueryConverter();
- return convert(converter.convert(query));
+ return convertBooleanQuery((org.apache.lucene.search.BooleanQuery)luceneQuery);
}
else
{
- throw new QueryConversionException("Unknown query type: " + query);
+ throw new QueryConversionException("Unknown query type: " + luceneQuery.getClass());
}
}
-
- public abstract Query convertTermQuery(TermQuery query);
+ public abstract Query convertTermQuery(org.apache.lucene.search.TermQuery query);
- public abstract Query convertBooleanQuery(BooleanQuery query) throws QueryConversionException;
+ public abstract Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery query) throws QueryConversionException;
}
Deleted: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/QueryImpl.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -1,39 +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.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/SimpleQueryConverter.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/SimpleQueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.SimpleQuery;
+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 SimpleQueryConverter extends AbstractQueryConverter
+{
+
+ 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((SimpleQuery)convert(luceneClause.query), luceneClause.required, luceneClause.prohibited));
+ }
+ catch (QueryConversionException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ return new BooleanQuery(clauses);
+ }
+
+
+}
+
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/StandardQueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -25,6 +25,7 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
@@ -41,12 +42,15 @@
public class StandardQueryConverter implements QueryConverter
{
- public Query convert(Query query) throws QueryConversionException
+ public Query convert(FederatedQuery query) throws QueryConversionException
{
- org.apache.lucene.search.Query luceneQuery = ((LuceneQuery) query).getLuceneQuery();
- return convertFromLucene(luceneQuery);
+// org.apache.lucene.search.Query luceneQuery = ((LuceneQuery) query).getLuceneQuery();
+// return convertFromLucene(luceneQuery);
+ return null;
}
+
+ /*
public Query convertFromLucene(org.apache.lucene.search.Query luceneQuery) throws QueryConversionException
{
if (luceneQuery == null)
@@ -92,5 +96,6 @@
}
return new BooleanQuery(clauses);
}
+ */
}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/jcr/JCRQueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -25,13 +25,11 @@
import java.util.Iterator;
import java.util.List;
+import org.apache.lucene.search.BooleanClause;
+import org.jboss.portal.search.FederatedQuery;
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>
@@ -40,7 +38,7 @@
public class JCRQueryConverter extends AbstractQueryConverter
{
- public Query convert(Query query)
+ public Query convert(FederatedQuery query)
{
if (query == null)
{
@@ -60,35 +58,33 @@
return new JCRQuery(result.toString());
}
- public Query convertTermQuery(TermQuery query)
+ public Query convertTermQuery(org.apache.lucene.search.TermQuery query)
{
-
StringBuffer result = new StringBuffer();
- Term term = query.getTerm();
- result.append("jcr:contains(., '" + term.getText() + "')");
+ org.apache.lucene.index.Term term = query.getTerm();
+ result.append("jcr:contains(., '" + term.text() + "')");
return new JCRQuery(result.toString());
}
- public Query convertBooleanQuery(BooleanQuery query) throws QueryConversionException
+ public Query convertBooleanQuery(org.apache.lucene.search.BooleanQuery query) throws QueryConversionException
{
- List clauses = query.getClauses();
+ BooleanClause[] clauses = query.getClauses();
StringBuffer result = new StringBuffer();
- Iterator it = clauses.iterator();
boolean first = true;
- while (it.hasNext())
+ for (int i=0; i<clauses.length; i++)
{
- BooleanClause clause = (BooleanClause)it.next();
+ BooleanClause clause = clauses[i];
if (!first)
{
result.append(", ");
}
- if (!clause.isProhibited())
+ if (!clause.prohibited)
{
- result.append(((JCRQuery)super.convert(clause.getQuery())).getJcrQuery());
+ result.append(((JCRQuery)convert(clause.query)).getJcrQuery());
first = false;
}
}
Added: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedIndexer.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -0,0 +1,134 @@
+/******************************************************************************
+ * 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.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.jboss.portal.search.IndexingException;
+import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.impl.AbstractFederatedIndexer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public abstract class LuceneFederatedIndexer extends AbstractFederatedIndexer
+{
+ private IndexWriter index;
+
+ private String indexPath;
+
+ public LuceneFederatedIndexer(String id, String indexPath)
+ {
+ this.id = id;
+ this.indexPath = indexPath;
+ }
+
+ public void createIndex() 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;
+ }
+
+ /**
+ * List of GenericDocument
+ * @return
+ */
+ public abstract List getDocuments();
+
+ public void destroyIndex()
+ {
+ info.setStatus(Info.Status.STOPPED);
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public Info getInfo()
+ {
+ return info;
+ }
+
+}
+
Copied: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java (from rev 7884, 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/impl/lucene/LuceneFederatedSearcher.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneFederatedSearcher.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.search.Hits;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.Searcher;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.impl.AbstractFederatedSearcher;
+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 abstract class LuceneFederatedSearcher extends AbstractFederatedSearcher
+{
+
+ private String id;
+
+ private String indexPath;
+
+ public LuceneFederatedSearcher(String id, String indexPath)
+ {
+ this.id = id;
+ this.indexPath = indexPath;
+ }
+
+
+ public ResultSet search(Query query)
+ {
+ ResultSet result = new ResultSet(this);
+ try
+ {
+ Searcher searcher = new IndexSearcher(indexPath);
+ Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
+ for (int i=0; i<hits.length(); i++)
+ {
+ result.add(new SimpleResult(id, hits.doc(i)));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQuery.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,41 +22,23 @@
******************************************************************************/
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;
+import org.apache.lucene.search.Query;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class LuceneQuery implements Query
+public class LuceneQuery implements org.jboss.portal.search.Query
{
- private org.apache.lucene.search.Query query;
+ private Query luceneQuery;
- private Logger logger = Logger.getLogger(LuceneQuery.class);
-
- public LuceneQuery(String queryString)
+ public LuceneQuery(Query luceneQuery)
{
- try
- {
- query = QueryParser.parse(queryString, "all" , new StandardAnalyzer());
- }
- catch (ParseException e)
- {
- logger.debug("Cannot parse query: " + queryString);
- }
+ this.luceneQuery = luceneQuery;
}
- public LuceneQuery(org.apache.lucene.search.Query query)
+ public Query getLuceneQuery()
{
- this.query = query;
+ return luceneQuery;
}
-
- public org.apache.lucene.search.Query getLuceneQuery()
- {
- return query;
- }
}
Added: 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/impl/lucene/LuceneQueryConverter.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneQueryConverter.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -0,0 +1,44 @@
+/******************************************************************************
+ * 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.jboss.portal.search.FederatedQuery;
+import org.jboss.portal.search.Query;
+import org.jboss.portal.search.QueryConversionException;
+import org.jboss.portal.search.QueryConverter;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class LuceneQueryConverter implements QueryConverter
+{
+
+ public Query convert(FederatedQuery query) throws QueryConversionException
+ {
+ return new LuceneQuery(query.getLuceneQuery());
+ }
+
+
+}
+
Deleted: 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/impl/lucene/LuceneSearchFederated.java 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/impl/lucene/LuceneSearchFederated.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -1,185 +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.impl.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.Query;
-import org.jboss.portal.search.FederatedSearcher;
-import org.jboss.portal.search.federation.Info;
-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;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public abstract class LuceneSearchFederated implements FederatedSearcher
-{
-
- 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;
- }
-
- /**
- * List of GenericDocument
- * @return
- */
- 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);
- try
- {
- Searcher searcher = new IndexSearcher(indexPath);
- Hits hits = searcher.search(((LuceneQuery)query).getLuceneQuery());
- 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();
- }
-
-}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanClause.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,7 +22,9 @@
******************************************************************************/
package org.jboss.portal.search.query;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -30,20 +32,20 @@
*/
public class BooleanClause
{
- private Query query;
+ private SimpleQuery query;
private boolean isRequired;
private boolean isProhibited;
- public BooleanClause(Query query, boolean isRequired, boolean isProhibited)
+ public BooleanClause(SimpleQuery query, boolean isRequired, boolean isProhibited)
{
this.query = query;
this.isRequired = isRequired;
this.isProhibited = isProhibited;
}
- public Query getQuery()
+ public SimpleQuery getQuery()
{
return query;
}
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/BooleanQuery.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -24,13 +24,13 @@
import java.util.List;
-import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class BooleanQuery implements Query
+public class BooleanQuery extends SimpleQuery
{
private List clauses;
Modified: 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 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/query/TermQuery.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,13 +22,13 @@
******************************************************************************/
package org.jboss.portal.search.query;
-import org.jboss.portal.search.Query;
+import org.jboss.portal.search.SimpleQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class TermQuery implements Query
+public class TermQuery extends SimpleQuery
{
private Term term;
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/ConverterTest.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -24,17 +24,16 @@
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.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.QueryConversionException;
import org.jboss.portal.search.QueryConverter;
-import org.jboss.portal.search.impl.QueryImpl;
+import org.jboss.portal.search.SimpleQuery;
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 org.jboss.portal.search.query.Term;
+import org.jboss.portal.search.query.TermQuery;
/**
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -53,25 +52,14 @@
public void testJCRConverter()
{
- org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id", "1"));
- Query query = new LuceneQuery(luceneQuery);
+
+ FederatedQuery fQuery = new FederatedQuery("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(., '1')]", xpath.toString());
+ JCRQuery xpath = (JCRQuery)converter.convert(fQuery);
+ assertEquals("//*[jcr:contains(., 'bar')]", xpath.toString());
}
catch (QueryConversionException e)
{
@@ -81,19 +69,8 @@
public void testJCRConverterMultipleTerms()
{
- Query query = new QueryImpl("foo bar");
+ FederatedQuery query = new FederatedQuery("foo bar");
- StandardQueryConverter standardConverter = new StandardQueryConverter();
- try
- {
- query = standardConverter.convert(query);
- }
- catch (QueryConversionException e)
- {
- // FIXME
- e.printStackTrace();
- }
-
QueryConverter converter = new JCRQueryConverter();
try
{
@@ -105,5 +82,4 @@
e.printStackTrace();
}
}
-
}
Modified: branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/DummyFederatedSearch.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -22,14 +22,14 @@
******************************************************************************/
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.FederatedSearcher;
import org.jboss.portal.search.IndexingException;
import org.jboss.portal.search.Query;
-import org.jboss.portal.search.FederatedSearcher;
+import org.jboss.portal.search.QueryConverter;
import org.jboss.portal.search.federation.Info;
+import org.jboss.portal.search.impl.lucene.LuceneQueryConverter;
import org.jboss.portal.search.result.ResultSet;
import org.jboss.portal.search.result.impl.SimpleResult;
@@ -87,5 +87,10 @@
{
return null;
}
+
+ public QueryConverter getQueryConverter()
+ {
+ return new LuceneQueryConverter();
+ }
}
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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/FederationTest.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -26,6 +26,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.TermQuery;
+import org.jboss.portal.search.FederatedQuery;
import org.jboss.portal.search.Query;
import org.jboss.portal.search.SearchingException;
import org.jboss.portal.search.federation.IndexFederation;
@@ -54,8 +55,10 @@
indexfederation.register(federatedSearch);
indexfederation.reindexAll();
+
+
org.apache.lucene.search.Query luceneQuery = new TermQuery(new Term("id", "1"));
- Query query = new LuceneQuery(luceneQuery);
+ FederatedQuery query = new FederatedQuery(luceneQuery);
List list = searchfederation.search(query);
ResultSet results = (ResultSet)list.get(0);
Deleted: 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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/LuceneQueryTest.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -1,64 +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 junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class LuceneQueryTest extends TestCase
-{
-
- /*
- public void test01()
- {
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("Title", "My Title"));
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- assertEquals(" +Title:\"My Title\" +id:\"1\"", LuceneQueryConverter.convert(query));
- }
-
- public void test02()
- {
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("Title", "My Title"));
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- query.addNotTerm(new BetweenDatesTerm("date", 10000, 20000));
- assertEquals(" +Title:\"My Title\" +id:\"1\" -date:[10000,20000]", LuceneQueryConverter.convert(query));
- }
-
- public void test03() throws IndexingException
- {
- LuceneSearchFederated fed = new TestLuceneSearchFederated("TestSearch", "test", "id");
- fed.create();
-
- Query query = new Query();
- query.addMandatoryTerm(new FieldQueryTerm("id", "1"));
- ResultSet results = fed.search(query);
- System.out.println(fed.getMarkup(results, 0));
- assertEquals("Id:1 Id:1 cat ", fed.getMarkup(results, 0));
- }
- */
-}
Deleted: 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-10 07:32:05 UTC (rev 7893)
+++ branches/JBoss_Portal_Branch_2_6/search/src/main/org/jboss/portal/search/test/TestLuceneSearchFederated.java 2007-08-10 13:07:59 UTC (rev 7894)
@@ -1,72 +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.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
-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>
- * @version $Revision$
- */
-public class TestLuceneSearchFederated extends LuceneSearchFederated
-{
-
- public TestLuceneSearchFederated(String id, String indexPath, String defaultField)
- {
- super(id, indexPath, defaultField);
- }
-
- public List getLuceneDocuments()
- {
- List result = new ArrayList();
-
- Document doc1 = new Document();
- doc1.add(Field.Text("id", "1"));
- result.add(doc1);
-
- Document doc2 = new Document();
- doc2.add(Field.Text("id", "1 cat"));
- result.add(doc2);
-
- return result;
- }
-
- public List getDocuments()
- {
- return null;
- }
-
- public LocalizedString getDisplayName()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
16 years, 10 months
JBoss Portal SVN: r7893 - trunk/core-cms/src/resources/portal-cms-sar/META-INF.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-08-10 03:32:05 -0400 (Fri, 10 Aug 2007)
New Revision: 7893
Modified:
trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
Adding missing dependency
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 06:10:26 UTC (rev 7892)
+++ trunk/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 07:32:05 UTC (rev 7893)
@@ -566,5 +566,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, 10 months
JBoss Portal SVN: r7892 - branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2007-08-10 02:10:26 -0400 (Fri, 10 Aug 2007)
New Revision: 7892
Modified:
branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1609 - cms cache dependency on cms service is flipped
Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 06:05:30 UTC (rev 7891)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 06:10:26 UTC (rev 7892)
@@ -43,7 +43,8 @@
<!-- The datasource hibernate depends on, it can be commented when the file store is used -->
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
<depends>portal:service=JAASLoginModule</depends>
- <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>portal:service=Hibernate,type=CMS</depends>
+ <depends>cms.pm.cache:service=TreeCache</depends>
<attribute name="DoChecking">true</attribute>
<attribute name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
<attribute name="DefaultLocale">en</attribute>
@@ -236,12 +237,9 @@
<!-- TreeCache configuration used to cache CMS data -->
<mbean code="org.jboss.cache.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, 10 months
JBoss Portal SVN: r7891 - branches/JBoss_Portal_Branch_2_6/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 02:05:30 -0400 (Fri, 10 Aug 2007)
New Revision: 7891
Modified:
branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml
Log:
JBPORTAL-1609 - cms cache dependency on cms service is flipped
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-10 05:44:19 UTC (rev 7890)
+++ branches/JBoss_Portal_Branch_2_6/core-cms/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2007-08-10 06:05:30 UTC (rev 7891)
@@ -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>
-
+ <depends>portal:service=Hibernate,type=CMS</depends>
<!--
Configure the TransactionManager
-->
16 years, 10 months
JBoss Portal SVN: r7890 - branches/JBoss_Portal_Branch_2_6/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 01:44:19 -0400 (Fri, 10 Aug 2007)
New Revision: 7890
Modified:
branches/JBoss_Portal_Branch_2_6/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_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
===================================================================
--- branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-10 05:01:23 UTC (rev 7889)
+++ branches/JBoss_Portal_Branch_2_6/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-10 05:44:19 UTC (rev 7890)
@@ -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,30 +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())
- {
+ {
long fileSize = zipEntry.getSize();
- if ((fileSize < 0) || (fileSize > Integer.MAX_VALUE))
- {
- throw new Exception("Error : " + itemName + " Cannot determine uncompressed size!");
- }
+ byte[] zipBytes = new byte[(int)fileSize];
+ InputStream zipDataStream = zipFile.getInputStream(zipEntry);
+ long bytesRead = 0;
- byte[] zipBytes = new byte[(int)fileSize];
- int offset = 0;
- while (offset < zipBytes.length)
+ 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);
@@ -103,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);
@@ -139,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);
@@ -167,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;
+ }
+}
\ No newline at end of file
16 years, 10 months
JBoss Portal SVN: r7889 - trunk/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 01:01:23 -0400 (Fri, 10 Aug 2007)
New Revision: 7889
Modified:
trunk/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: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-10 04:54:14 UTC (rev 7888)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/StoreArchiveCommand.java 2007-08-10 05:01:23 UTC (rev 7889)
@@ -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,30 +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())
- {
+ {
long fileSize = zipEntry.getSize();
- if ((fileSize < 0) || (fileSize > Integer.MAX_VALUE))
- {
- throw new Exception("Error : " + itemName + " Cannot determine uncompressed size!");
- }
+ byte[] zipBytes = new byte[(int)fileSize];
+ InputStream zipDataStream = zipFile.getInputStream(zipEntry);
+ long bytesRead = 0;
- byte[] zipBytes = new byte[(int)fileSize];
- int offset = 0;
- while (offset < zipBytes.length)
+ 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);
@@ -103,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);
@@ -139,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);
@@ -167,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;
+ }
+}
\ No newline at end of file
16 years, 10 months