portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r944338 - in /portals/applications/sandbox/content/trunk/src/main: java/org/apache/portals/applications/content/ java/org/apache/portals/applications/content/query/ webapp/WEB-INF/ webapp/WEB-INF/classes/ webapp/WEB-INF/view/
Date Fri, 14 May 2010 16:41:20 GMT
Author: woonsan
Date: Fri May 14 16:41:20 2010
New Revision: 944338

URL: http://svn.apache.org/viewvc?rev=944338&view=rev
Log:
Improving generic query portlet

Added:
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/DelegatingQueryManager.java
  (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/webapp/WEB-INF/classes/log4j.properties
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-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=944338&r1=944337&r2=944338&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
Fri May 14 16:41:20 2010
@@ -28,6 +28,7 @@ import org.apache.jackrabbit.ocm.manager
 import org.apache.jackrabbit.ocm.query.Filter;
 import org.apache.jackrabbit.ocm.query.Query;
 import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.apache.portals.applications.content.query.DelegatingQueryManager;
 
 
 /**
@@ -52,8 +53,22 @@ public class GenericQueryContentPortlet 
         
         try
         {
-            Class<?> queryClass = Thread.currentThread().getContextClassLoader().loadClass(queryClassName);
+            final String queryOrderByClause = request.getPreferences().getValue("queryOrderByClause",
null);
             QueryManager queryManager = ocm.getQueryManager();
+            
+            if (!StringUtils.isBlank(queryOrderByClause))
+            {
+                queryManager = new DelegatingQueryManager(queryManager)
+                {
+                    @Override
+                    public String buildJCRExpression(Query query)
+                    {
+                        return super.buildJCRExpression(query) + " order by " + queryOrderByClause;
+                    }
+                };
+            }
+            
+            Class<?> queryClass = Thread.currentThread().getContextClassLoader().loadClass(queryClassName);
             Filter filter = createFilter(request, queryManager, queryClass, contentPath);
             Query query = queryManager.createQuery(filter);
             Collection result = ocm.getObjects(query);
@@ -84,6 +99,8 @@ public class GenericQueryContentPortlet 
                     list.add(item);
                     ++count;
                 }
+                
+                contentBean = list;
             }
             
             return contentBean;

Added: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/DelegatingQueryManager.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/DelegatingQueryManager.java?rev=944338&view=auto
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/DelegatingQueryManager.java
(added)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/query/DelegatingQueryManager.java
Fri May 14 16:41:20 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.query;
+
+import org.apache.jackrabbit.ocm.query.Filter;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+
+/**
+ * DelegatingQueryManager
+ * 
+ * @version $Id$
+ */
+public class DelegatingQueryManager implements QueryManager
+{
+    private QueryManager delegatee;
+    
+    public DelegatingQueryManager(QueryManager delegatee)
+    {
+        this.delegatee = delegatee;
+    }
+
+    public Query createQuery(Filter filter)
+    {
+        return delegatee.createQuery(filter);
+    }
+    
+    public Filter createFilter(Class classQuery)
+    {
+        return delegatee.createFilter(classQuery);
+    }
+    
+    public String buildJCRExpression(Query query)
+    {
+        return delegatee.buildJCRExpression(query);
+    }
+}

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

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

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

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/classes/log4j.properties
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/classes/log4j.properties?rev=944338&r1=944337&r2=944338&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/classes/log4j.properties
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/classes/log4j.properties
Fri May 14 16:41:20 2010
@@ -16,7 +16,7 @@
 #
 # Logging Configuration
 #
-# $Id:$
+# $Id$
 #
 # ------------------------------------------------------------------------
 
@@ -26,8 +26,11 @@
 #
 log4j.rootLogger = ERROR, pa
 
-log4j.category.org.apache.jetspeed = ERROR, pa
-log4j.additivity.org.apache.jetspeed = false
+log4j.category.org.apache.portals.applications.content = ERROR, pa
+log4j.additivity.org.apache.portals.applications.content = false
+
+log4j.category.org.apache.jackrabbit.ocm.manager = DEBUG, ocm
+log4j.additivity.org.apache.jackrabbit.ocm.manager = false
 
 ########################################################################
 #
@@ -36,10 +39,19 @@ log4j.additivity.org.apache.jetspeed = f
 ########################################################################
 
 #
-# demo.log
+# content.log
 #
 log4j.appender.pa = org.apache.log4j.FileAppender
 log4j.appender.pa.file = ${org.apache.portals.logdir}/content.log
 log4j.appender.pa.layout = org.apache.log4j.PatternLayout
 log4j.appender.pa.layout.conversionPattern = %d [%t] %-5p %c - %m%n
 log4j.appender.pa.append = false
+
+#
+# content-ocm.log
+#
+log4j.appender.ocm = org.apache.log4j.FileAppender
+log4j.appender.ocm.file = ${org.apache.portals.logdir}/content-ocm.log
+log4j.appender.ocm.layout = org.apache.log4j.PatternLayout
+log4j.appender.ocm.layout.conversionPattern = %d [%t] %-5p %c - %m%n
+log4j.appender.ocm.append = false

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=944338&r1=944337&r2=944338&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 Fri May
14 16:41:20 2010
@@ -105,8 +105,8 @@
         <value>10</value>
       </preference>
       <preference>
-        <name>queryJCRExpression</name>
-        <value></value>
+        <name>queryOrderByClause</name>
+        <value>@onehippo:documentdate descending</value>
       </preference>
     </portlet-preferences>
   </portlet>
@@ -197,8 +197,8 @@
         <value>10</value>
       </preference>
       <preference>
-        <name>queryJCRExpression</name>
-        <value></value>
+        <name>queryOrderByClause</name>
+        <value>@onehippo:documentdate descending</value>
       </preference>
     </portlet-preferences>
   </portlet>

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp?rev=944338&r1=944337&r2=944338&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-view.jsp
Fri May 14 16:41:20 2010
@@ -20,11 +20,9 @@ limitations under the License.
 
 <h1>Content query result</h1>
 <hr/>
-<table>
-  <c:forEach var="content" items="${contentBean}">
-    <tr>
-	  <td>Title:</td>
-	  <td>${contentBean.title}</td>
-	</tr>
-  </c:forEach>
-</table>
+
+<c:forEach var="contentItem" items="${contentBean}">
+<h3>${contentItem.title}</h3>
+<div>${contentItem.introduction}</div>
+<p>&nbsp;</p>
+</c:forEach>



Mime
View raw message