portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r945087 - in /portals/applications/sandbox/content/trunk/src/main: java/org/apache/portals/applications/content/ java/org/apache/portals/applications/content/demo/beans/ webapp/WEB-INF/ webapp/WEB-INF/view/
Date Mon, 17 May 2010 11:20:28 GMT
Author: woonsan
Date: Mon May 17 11:20:27 2010
New Revision: 945087

URL: http://svn.apache.org/viewvc?rev=945087&view=rev
Log:
Adding generic search content portlet

Added:
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
  (with props)
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
  (with props)
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
  (with props)
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
  (with props)
Modified:
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp

Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java?rev=945087&r1=945086&r2=945087&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
(original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericQueryContentPortlet.java
Mon May 17 11:20:27 2010
@@ -169,6 +169,7 @@ public class GenericQueryContentPortlet 
         String query = getParameterOrPreference(request, "query", null);
         String queryNode = getParameterOrPreference(request, "queryNode", ".");
         String queryOperator = getParameterOrPreference(request, "queryOperator", "contains");
+        String queryJcrExpression = getParameterOrPreference(request, "queryJcrExpression",
null);
         
         if (query != null)
         {
@@ -182,6 +183,31 @@ public class GenericQueryContentPortlet 
             }
         }
         
+        if (!StringUtils.isBlank(queryJcrExpression))
+        {
+            filter.addJCRExpression(queryJcrExpression);
+        }
+        
+        if (query != null)
+        {
+            request.setAttribute("query", query);
+        }
+        
+        if (queryNode != null)
+        {
+            request.setAttribute("queryNode", queryNode);
+        }
+        
+        if (queryOperator != null)
+        {
+            request.setAttribute("queryOperator", queryOperator);
+        }
+        
+        if (queryJcrExpression != null)
+        {
+            request.setAttribute("queryJcrExpression", queryJcrExpression);
+        }
+        
         return filter;
     }
     

Added: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java?rev=945087&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
(added)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
Mon May 17 11:20:27 2010
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.applications.content;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequest;
+
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+
+
+/**
+ * GenericSearchQueryContentPortlet
+ * 
+ * @version $Id$
+ */
+public class GenericSearchQueryContentPortlet extends GenericQueryContentPortlet 
+{
+    @Override
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
IOException
+    {
+        String query = request.getParameter("query");
+        String queryNode = request.getParameter("queryNode");
+        String queryOperator = request.getParameter("queryOperator");
+        String queryJcrExpression = request.getParameter("queryJcrExpression");
+        
+        if (query != null)
+        {
+            response.setRenderParameter("query", query);
+        }
+        
+        if (queryNode != null)
+        {
+            response.setRenderParameter("queryNode", queryNode);
+        }
+        
+        if (queryOperator != null)
+        {
+            response.setRenderParameter("queryOperator", queryOperator);
+        }
+        
+        if (queryJcrExpression != null)
+        {
+            response.setRenderParameter("queryJcrExpression", queryJcrExpression);
+        }
+        
+        super.processAction(request, response);
+    }
+    
+    @Override
+    protected Object getContentBean(final PortletRequest request, final ObjectContentManager
ocm, final String contentPath) throws PortletException
+    {
+        String query = request.getParameter("query");
+        
+        if (query == null)
+        {
+            return null;
+        }
+        
+        return super.getContentBean(request, ocm, contentPath);
+    }
+}

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java?rev=945087&r1=945086&r2=945087&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
(original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/demo/beans/TextPage.java
Mon May 17 11:20:27 2010
@@ -34,7 +34,7 @@ public class TextPage 
     protected Date documentDate;
     protected String title;
     protected String introduction; 
-    protected HtmlBodyContent bodyContent;
+    protected HtmlBodyContent body;
     
     @Field(path=true)
     public String getPath() 
@@ -81,13 +81,13 @@ public class TextPage 
     }
     
     @Bean(jcrName="onehippo:body", proxy=true)
-    public HtmlBodyContent getBodyContent()
+    public HtmlBodyContent getBody()
     {
-        return bodyContent;
+        return body;
     }
     
-    public void setBodyContent(HtmlBodyContent bodyContent)
+    public void setBody(HtmlBodyContent body)
     {
-        this.bodyContent = bodyContent;
+        this.body = body;
     }
 }

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=945087&r1=945086&r2=945087&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml Mon May
17 11:20:27 2010
@@ -101,8 +101,58 @@
         <value>org.apache.portals.applications.content.demo.beans.TextPage</value>
       </preference>
       <preference>
-        <name>beginIndex</name>
-        <value>0</value>
+        <name>pageSize</name>
+        <value>10</value>
+      </preference>
+      <preference>
+        <name>queryOrderByClause</name>
+        <value>@onehippo:documentdate descending</value>
+      </preference>
+    </portlet-preferences>
+  </portlet>
+  
+  <portlet id="GenericSearchQueryContentPortlet">
+    <description>Generic Search Query Content Portlet</description>
+    <portlet-name>Generic Search QueryContentPortlet</portlet-name>
+    <display-name>Generic Search Query Content</display-name>
+    <portlet-class>org.apache.portals.applications.content.GenericSearchQueryContentPortlet</portlet-class>
+    <init-param>
+      <name>ViewPage</name>
+      <value>/WEB-INF/view/generic-search-query-content-view.jsp</value>
+    </init-param>
+    <init-param>
+      <name>EditPage</name>
+      <value>/WEB-INF/view/generic-search-query-content-edit.jsp</value>
+    </init-param>
+    <init-param>
+      <name>HelpPage</name>
+      <value>/WEB-INF/view/generic-search-query-content-help.jsp</value>
+    </init-param>
+    <expiration-cache>0</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>EDIT</portlet-mode>
+      <portlet-mode>VIEW</portlet-mode>
+      <portlet-mode>HELP</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>Generic Search Query Content</title>
+      <short-title>Generic Search Query Content</short-title>
+      <keywords>content,search,query</keywords>
+    </portlet-info>
+    <portlet-preferences>
+      <preference>
+        <name>contentPath</name>
+        <value>/content/documents/en//</value>
+      </preference>
+      <preference>
+        <name>contentUrlBase</name>
+        <value>/content/documents/en</value>
+      </preference>
+      <preference>
+        <name>queryClass</name>
+        <value>org.apache.portals.applications.content.demo.beans.TextPage</value>
       </preference>
       <preference>
         <name>pageSize</name>
@@ -110,7 +160,7 @@
       </preference>
       <preference>
         <name>queryOrderByClause</name>
-        <value>@onehippo:documentdate descending</value>
+        <value>@jcr:score descending</value>
       </preference>
     </portlet-preferences>
   </portlet>
@@ -197,10 +247,6 @@
         <value>org.apache.portals.applications.content.demo.beans.NewsItem</value>
       </preference>
       <preference>
-        <name>beginIndex</name>
-        <value>0</value>
-      </preference>
-      <preference>
         <name>pageSize</name>
         <value>10</value>
       </preference>

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp?rev=945087&r1=945086&r2=945087&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-view.jsp
Mon May 17 11:20:27 2010
@@ -37,4 +37,4 @@ limitations under the License.
 
 <hr/>
 
-${contentBean.bodyContent.content}
+${contentBean.body.content}

Added: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp?rev=945087&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
(added)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
Mon May 17 11:20:27 2010
@@ -0,0 +1,22 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<h1>Content search query result edit page</h1>
+<hr/>

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp?rev=945087&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
(added)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
Mon May 17 11:20:27 2010
@@ -0,0 +1,22 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<h1>Content search query result help page</h1>
+<hr/>

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-help.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp?rev=945087&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
(added)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
Mon May 17 11:20:27 2010
@@ -0,0 +1,96 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page import="org.apache.jetspeed.request.RequestContext"%>
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
+<%@ taglib prefix="c_rt" uri="http://java.sun.com/jstl/core_rt" %>
+<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
+<portlet:defineObjects/>
+
+<c_rt:set var="requestContext" value="<%=request.getAttribute(RequestContext.REQUEST_PORTALENV)%>"/>
+<c:set var="portalContextPath" value="${requestContext.request.contextPath}" />
+<c:if test="${empty portalContextPath}">
+  <c:set var="portalContextPath" value="/"/>
+</c:if>
+<c:set var="portalServletPath" value="${requestContext.request.servletPath}" />
+
+<h1>Content search query result</h1>
+<hr/>
+
+<form action="<portlet:actionURL/>">
+Query:
+<input type="text" name="query" value="${query}" />
+<input type="submit" name="submit" value="Search"/>
+<br/>
+Search bean property:
+<select name="queryNode">
+  <option value=".">Any</option>
+  <c:forTokens var="beanProp" items="title;introduction;body" delims=";">
+    <c:choose>
+      <c:when test="${beanProp == queryNode}">
+        <option value="${beanProp}" selected="true">${beanProp}</option>
+      </c:when>
+      <c:otherwise>
+        <option value="${beanProp}">${beanProp}</option>
+      </c:otherwise>
+    </c:choose>
+  </c:forTokens>
+</select>
+Search Operator:
+<select name="queryOperator">
+  <c:choose>
+    <c:when test="${queryOperator == 'equalto'}">
+      <option value="contains">Contains</option>
+      <option value="equalto" selected="true">Equal to</option>
+    </c:when>
+    <c:otherwise>
+	  <option value="contains">Contains</option>
+	  <option value="equalto">Equal to</option>
+    </c:otherwise>
+  </c:choose>
+</select>
+<br/>
+Additional custom JCR expression: <input type="text" name="queryJcrExpression" value="${queryJcrExpression}"
/>
+</form>
+
+<hr/>
+
+<c:forEach var="contentItem" items="${contentBean}">
+<h3><a href="${portalContextPath}${portalServletPath}${fn:substringAfter(contentItem.path,
contentUrlBase)}">${contentItem.title}</a></h3>
+<div align="right">(${contentItem.documentDate})</div>
+<div>${contentItem.introduction}</div>
+<p>&nbsp;</p>
+</c:forEach>
+
+<hr/>
+
+Pages: 
+<c:forEach begin="1" end="${pageCount}" var="index">
+  &nbsp;
+  <c:choose>
+    <c:when test="${index == pageIndex}">
+      ${index}
+    </c:when>
+    <c:otherwise>
+      <portlet:renderURL var="pageURL">
+        <portlet:param name="page" value="${index}"/>
+      </portlet:renderURL>
+      <a href="${pageURL}">${index}</a>
+    </c:otherwise>
+  </c:choose>
+  &nbsp;
+</c:forEach>

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-view.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp?rev=945087&r1=945086&r2=945087&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/news-item-view.jsp
Mon May 17 11:20:27 2010
@@ -37,4 +37,4 @@ limitations under the License.
 
 <hr/>
 
-${contentBean.bodyContent.content}
+${contentBean.body.content}



Mime
View raw message