[Registry-dev] svn commit r9953 - in trunk/registry/modules/core/src: main/java/org/wso2/registry main/java/org/wso2/registry/client main/java/org/wso2/registry/inmemory main/java/org/wso2/registry/jdbc main/java/org/wso2/registry/jdbc/dao main/java/org/wso2/registry/secure test/java/org/wso2/registry/jdbc

svn at wso2.org svn at wso2.org
Tue Nov 20 01:57:45 PST 2007


Author: chathura
Date: Tue Nov 20 01:57:33 2007
New Revision: 9953

Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
   trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
Log:

Improved the audit log to filter logs by action (e.g. logs on comments, tags, resource updates).



Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java	Tue Nov 20 01:57:33 2007
@@ -202,6 +202,6 @@
      *
      * @throws RegistryException
      */
-    LogEntry[] getLogs(String resourcePath, String userName, Date from, Date to)
+    LogEntry[] getLogs(String resourcePath, int action, String userName, Date from, Date to)
             throws RegistryException;
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java	Tue Nov 20 01:57:33 2007
@@ -117,7 +117,8 @@
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public LogEntry[] getLogs(String resourcePath, String userName, Date from, Date to) throws RegistryException {
+    public LogEntry[] getLogs(String resourcePath, int action, String userName, Date from, Date to)
+            throws RegistryException {
         return new LogEntry[0];  //To change body of implemented methods use File | Settings | File Templates.
     }
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java	Tue Nov 20 01:57:33 2007
@@ -290,7 +290,8 @@
         resourceMap.remove(resourcePath);
     }
 
-    public LogEntry[] getLogs(String resourcePath, String userName, Date from, Date to) throws RegistryException {
+    public LogEntry[] getLogs(String resourcePath, int action, String userName, Date from, Date to)
+            throws RegistryException {
         throw new UnsupportedOperationException(
                 "Logs are not supported in HashMap based in-memory registry.");
     }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	Tue Nov 20 01:57:33 2007
@@ -812,6 +812,7 @@
     }
 
     public LogEntry[] getLogs(String resourcePath,
+                              int action,
                               String userName,
                               Date from, Date to) throws RegistryException {
 
@@ -820,7 +821,7 @@
         List logEntryList;
 
         try {
-            logEntryList = logsDAO.getLogs(resourcePath, userName, from, to, conn);
+            logEntryList = logsDAO.getLogs(resourcePath, action, userName, from, to, conn);
             
         } catch (SQLException e) {
             String msg = "Could not get logs. Caused by: " + e.getMessage();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/LogsDAO.java	Tue Nov 20 01:57:33 2007
@@ -42,9 +42,8 @@
         s.executeUpdate();
     }
 
-    public List getLogs(String resourcePath,
-                              String userName,
-                              Date from, Date to, Connection conn) throws SQLException {
+    public List getLogs(String resourcePath, int action,
+                        String userName, Date from, Date to, Connection conn) throws SQLException {
 
         ResourceDAO resourceDAO = new ResourceDAO();
 
@@ -71,6 +70,10 @@
             sql = sql + " AND L.LOGGED_TIME<?";
         }
 
+        if (action != -1) {
+            sql = sql + " AND L.ACTION=?";
+        }
+
         PreparedStatement s = conn.prepareStatement(sql);
 
         int paramNumber = 1;
@@ -95,6 +98,11 @@
             paramNumber++;
         }
 
+        if (action != -1) {
+            s.setInt(paramNumber, action);
+            paramNumber++;
+        }
+
         ResultSet results = s.executeQuery();
 
         List resultList = new ArrayList();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java	Tue Nov 20 01:57:33 2007
@@ -274,8 +274,9 @@
         return registry.executeQuery(path, parameters);
     }
 
-    public LogEntry[] getLogs(String resourcePath, String userName, Date from, Date to) throws RegistryException {
+    public LogEntry[] getLogs(String resourcePath, int action, String userName, Date from, Date to)
+            throws RegistryException {
         User.setCurrentUser(userID);
-        return registry.getLogs(resourcePath, userName, from, to);
+        return registry.getLogs(resourcePath, action, userName, from, to);
     }
 }

Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java	(original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java	Tue Nov 20 01:57:33 2007
@@ -958,7 +958,7 @@
 
         registry.rateResource("/r200", 5);
 
-        LogEntry[] logs = registry.getLogs("/r200", null, null, null);
+        LogEntry[] logs = registry.getLogs("/r200", -1, null, null, null);
 
         LogEntry l1 = logs[0];
         assertEquals("Log for adding /r200 is not added properly.", LogEntry.UPDATE, l1.getAction());



More information about the Registry-dev mailing list