portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r330699 - in /portals/jetspeed-2/trunk/applications/pam: ./ src/java/org/apache/jetspeed/portlets/statistics/ src/webapp/WEB-INF/ src/webapp/WEB-INF/view/statistics/
Date Fri, 04 Nov 2005 04:07:36 GMT
Author: taylor
Date: Thu Nov  3 20:07:28 2005
New Revision: 330699

URL: http://svn.apache.org/viewcvs?rev=330699&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-362
start of statistics portlet

Added:
    portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/
    portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/StatisticsPortlet.java
    portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/
    portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/statistics.vm
Modified:
    portals/jetspeed-2/trunk/applications/pam/project.xml
    portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/portlet.xml

Modified: portals/jetspeed-2/trunk/applications/pam/project.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/pam/project.xml?rev=330699&r1=330698&r2=330699&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/pam/project.xml (original)
+++ portals/jetspeed-2/trunk/applications/pam/project.xml Thu Nov  3 20:07:28 2005
@@ -116,6 +116,14 @@
             </properties>
         </dependency>
         <dependency>
+            <id>jetspeed2:jetspeed-statistics</id> 
+            <version>${jetspeed.version}</version>
+            <type>jar</type>
+            <properties>
+                <war.bundle>true</war.bundle>
+            </properties>
+        </dependency>
+        <dependency>
             <id>jetspeed2:jetspeed2-taglib-treecontrol</id>
             <version>${jetspeed.version}</version>
             <type>jar</type>

Added: portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/StatisticsPortlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/StatisticsPortlet.java?rev=330699&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/StatisticsPortlet.java
(added)
+++ portals/jetspeed-2/trunk/applications/pam/src/java/org/apache/jetspeed/portlets/statistics/StatisticsPortlet.java
Thu Nov  3 20:07:28 2005
@@ -0,0 +1,109 @@
+/*
+ * Created on Nov 3, 2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.jetspeed.portlets.statistics;
+
+import java.io.IOException;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletConfig;
+import javax.portlet.PortletContext;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+
+import org.apache.jetspeed.CommonPortletServices;
+import org.apache.jetspeed.statistics.AggregateStatistics;
+import org.apache.jetspeed.statistics.InvalidCriteriaException;
+import org.apache.jetspeed.statistics.PortalStatistics;
+import org.apache.jetspeed.statistics.StatisticsQueryCriteria;
+import org.apache.jetspeed.statistics.impl.AggregateStatisticsImpl;
+import org.apache.jetspeed.statistics.impl.StatisticsQueryCriteriaImpl;
+import org.apache.portals.bridges.velocity.GenericVelocityPortlet;
+import org.apache.velocity.context.Context;
+
+
+/**
+ * Statistics Portlet
+ * 
+ * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer</a>
+ * @version $Id: $
+ */
+public class StatisticsPortlet extends GenericVelocityPortlet
+{
+    private PortalStatistics statistics;
+    
+    private static final String SESSION_CRITERIA = "criteria";
+    private static final String SESSION_RESULTS = "results";
+    
+    public void init(PortletConfig config) throws PortletException
+    {
+        super.init(config);
+        PortletContext context = getPortletContext();
+        statistics = (PortalStatistics)context.getAttribute(CommonPortletServices.CPS_PORTAL_STATISTICS);
+        if (statistics == null)
+            throw new PortletException("Could not get instance of portal statistics component");
+    }
+
+    public void doView(RenderRequest request, RenderResponse response) throws PortletException,
IOException
+    {
+        Context velocityContext = getContext(request);
+        PortletSession session = request.getPortletSession();
+        
+        StatisticsQueryCriteria test = new StatisticsQueryCriteriaImpl();
+        test.setQueryType("user");
+        session.setAttribute(SESSION_CRITERIA,test);
+        
+        StatisticsQueryCriteria sqc = (StatisticsQueryCriteria)session.getAttribute(SESSION_CRITERIA);
+        AggregateStatistics stats = (AggregateStatistics)session.getAttribute(SESSION_RESULTS);
+        if(stats == null) {
+            if(sqc != null) {
+                try
+                {
+                    stats = statistics.queryStatistics(sqc);
+                } catch (InvalidCriteriaException e)
+                {
+                    //TODO:  need to handle situation where we pass in invalid criteria also
SQL problem will come in here
+                }
+            }
+        }
+        velocityContext.put(SESSION_CRITERIA, sqc);
+        velocityContext.put(SESSION_RESULTS,stats);
+        velocityContext.put("mytest","this is a test");
+        super.doView(request, response);
+    }
+
+    public void processAction(ActionRequest request, ActionResponse actionResponse) throws
PortletException, IOException
+    {
+        PortletSession session = request.getPortletSession();
+        // TODO: build query
+        StatisticsQueryCriteria criteria = new StatisticsQueryCriteriaImpl();
+        String user = request.getParameter("user");
+        criteria.setUser(user);
+        String address = request.getParameter("address");
+        criteria.setIpAddress(address);
+        String queryType = request.getParameter("queryType");
+        
+        criteria.setQueryType(queryType);
+        // TODO: validate
+            // this copy will probalby get tosses.
+        AggregateStatistics stats = new AggregateStatisticsImpl();
+        try
+        {
+            stats = statistics.queryStatistics(criteria);
+        } catch (InvalidCriteriaException e)
+        {
+            //TODO:  need to handle situation where we pass in invalid criteria also SQL
problem will come in here
+        }
+        // save this to session for later display/edit
+        session.setAttribute(SESSION_CRITERIA,criteria);
+        session.setAttribute(SESSION_RESULTS,stats);
+        
+    }
+    
+}

Modified: portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=330699&r1=330698&r2=330699&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/jetspeed-portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/jetspeed-portlet.xml Thu
Nov  3 20:07:28 2005
@@ -45,6 +45,7 @@
 		<js:service name='GroupManager'/>
 		<js:service name='Profiler'/>		
         <js:service name='PermissionManager'/>
+        <js:service name='PortalStatistics'/>
 	</js:services>
 	
 </portlet-app>

Modified: portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/portlet.xml?rev=330699&r1=330698&r2=330699&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/portlet.xml Thu Nov  3 20:07:28
2005
@@ -293,4 +293,28 @@
       <keywords>applications,apps,entity,manager</keywords>
     </portlet-info>
   </portlet>
+
+<portlet id="StatisticsPortlet">
+    <init-param>
+        <description>This parameter sets the template used in view mode.</description>
+        <name>ViewPage</name>
+            <value>/WEB-INF/view/statistics/statistics.vm</value>
+     </init-param>
+    <portlet-name>StatisticsPortlet</portlet-name>
+    <display-name>Portal Statistics</display-name>
+    <description>Provides statistics about portal access by page, portlet, user</description>
+    <portlet-class>org.apache.jetspeed.portlets.statistics.StatisticsPortlet</portlet-class>
+    <expiration-cache>-1</expiration-cache>
+    <supports>
+      <mime-type>text/html</mime-type>
+      <portlet-mode>VIEW</portlet-mode>
+    </supports>
+    <supported-locale>en</supported-locale>
+    <portlet-info>
+      <title>Portal Statistics</title>
+      <short-title>Statistics</short-title>
+      <keywords>statistics,portlets,pages,access</keywords>
+    </portlet-info>
+  </portlet>
+  
 </portlet-app>

Added: portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/statistics.vm
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/statistics.vm?rev=330699&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/statistics.vm
(added)
+++ portals/jetspeed-2/trunk/applications/pam/src/webapp/WEB-INF/view/statistics/statistics.vm
Thu Nov  3 20:07:28 2005
@@ -0,0 +1,23 @@
+<h3 class="portlet-section-header">Portal Statistics</h3>
+
+<div id="StatisticsPortlet"  class="portlet-section-text"> 
+	<form action="$renderResponse.createActionURL()" method="post"
+	<table>
+	<tr><td>
+	 query type is 
+	 $criteria.queryType
+	 
+	 <input type="submit" name="Save" value="Save" />
+	 
+	</td></tr>
+	</table>
+	</form>
+	<table class="class="portlet-section-body" >
+	<tr class="portlet-section-subheader"><TH><b>stat name</b></TH><TH><b>value</b></TH></TR>
+	<tr class="portlet-section-alternate"><TD>total hits</TD><TD>$!results.hitCount</TD></TD>
+	<tr class="portlet-section-body"><TD>max processing time</TD><TD>$!results.maxProcessingTime</TD></TD>
+	<tr class="portlet-section-alternate"><TD>avg processing time</TD><TD>$!results.avgProcessingTime</TD></TD>
+	<tr class="portlet-section-body"><TD>stdev from avg time</TD><TD>$!results.stdDevProcessingTime</TD></TD>
+	<tr class="portlet-section-alternate"><TD>min processing time</TD><TD>$!results.minProcessingTime</TD></TD>
+    </table>
+</div>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message