[pal-cvs 3234] [970] added maxAge option to AuditActivity

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 6月 10日 (火) 21:46:23 JST


Revision: 970
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=970
Author:   shinsuke
Date:     2008-06-10 21:46:23 +0900 (Tue, 10 Jun 2008)

Log Message:
-----------
added maxAge option to AuditActivity

Modified Paths:
--------------
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java
    pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/statistics.xml


-------------- next part --------------
Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java	2008-06-10 05:22:30 UTC (rev 969)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/components/statistics/src/java/org/apache/jetspeed/audit/impl/AuditActivityImpl.java	2008-06-10 12:46:23 UTC (rev 970)
@@ -48,9 +48,12 @@
 
     protected boolean enabled = true;
 
+    protected int maxAge;
+
     public AuditActivityImpl(DataSource dataSource)
     {
         this.ds = dataSource;
+        maxAge = 0;
     }
 
     public void setEnabled(boolean enabled)
@@ -63,6 +66,16 @@
         return this.enabled;
     }
 
+    public int getMaxAge()
+    {
+        return maxAge;
+    }
+
+    public void setMaxAge(int maxAge)
+    {
+        this.maxAge = maxAge;
+    }
+
     public DataSource getDataSource()
     {
         return ds;
@@ -138,6 +151,14 @@
             stm.setString(9, afterValue);
             stm.setString(10, description);
             stm.execute();
+            if (maxAge > 0)
+            {
+                PreparedStatement stm2 = con
+                        .prepareStatement("DELETE FROM ADMIN_ACTIVITY WHERE TIME_STAMP < ?");
+                stm2.setTimestamp(1, new Timestamp(System.currentTimeMillis()
+                        + ((long) maxAge * 1000)));
+                stm2.execute();
+            }
         }
         catch (SQLException e)
         {
@@ -195,6 +216,15 @@
                 stm.setString(8, afterValue);
                 stm.setString(9, description);
                 stm.executeUpdate();
+                if (maxAge > 0)
+                {
+                    PreparedStatement stm2 = con
+                            .prepareStatement("DELETE FROM USER_ACTIVITY WHERE TIME_STAMP < ?");
+                    stm2.setTimestamp(1, new Timestamp(System
+                            .currentTimeMillis()
+                            + ((long) maxAge * 1000)));
+                    stm2.execute();
+                }
             }
             catch (SQLException e)
             {

Modified: pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/statistics.xml
===================================================================
--- pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/statistics.xml	2008-06-10 05:22:30 UTC (rev 969)
+++ pal-portal/branches/pal-portal-1.x/portal/jetspeed-2/src/webapp/WEB-INF/assembly/statistics.xml	2008-06-10 12:46:23 UTC (rev 970)
@@ -57,6 +57,8 @@
           >
       	<constructor-arg  index='0' ><ref bean="JetspeedDS" /></constructor-arg>
 		<property name="enabled"><value type='boolean'>true</value></property>          
+        <!-- 30days = 30 * 24 * 60 * 60 = 2592000 -->
+		<property name="maxAge"><value>2592000</value></property>          
 	</bean>
 		
 </beans>


pal-cvs メーリングリストの案内
Zurück zum Archiv-Index