← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9116: added some additional auditing when users are creating, updating and deleting identifiable objects

 

------------------------------------------------------------
revno: 9116
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-11-25 19:27:00 +0100
message:
  added some additional auditing when users are creating, updating and deleting identifiable objects
removed:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogUtil.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
  dhis-2/dhis-support/dhis-support-hibernate/pom.xml
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java	2012-11-25 18:27:00 +0000
@@ -0,0 +1,87 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import org.apache.commons.logging.Log;
+
+public class AuditLogUtil
+{
+    public static final String ACTION_CREATE = "create";
+    public static final String ACTION_READ = "read";
+    public static final String ACTION_UPDATE = "updated";
+    public static final String ACTION_DELETE = "deleted";
+
+    public static void infoWrapper( Log log, String username, Object object, String action )
+    {
+        if ( log.isInfoEnabled() )
+        {
+            if ( username != null && object != null && IdentifiableObject.class.isInstance( object ) )
+            {
+                IdentifiableObject idObject = (IdentifiableObject) object;
+                StringBuilder builder = new StringBuilder();
+
+                builder.append( "'" );
+                builder.append( username );
+                builder.append( "' " );
+                builder.append( action );
+                builder.append( " " );
+                builder.append( object.getClass().getName() );
+
+                if ( idObject.getName() != null && !idObject.getName().isEmpty() )
+                {
+                    builder.append( ", name: " );
+                    builder.append( idObject.getName() );
+                }
+
+                if ( idObject.getUid() != null && !idObject.getUid().isEmpty() )
+                {
+                    builder.append( ", uid: " );
+                    builder.append( idObject.getUid() );
+                }
+
+                // String msg = logMessage( username, action, object.getClass().getName(), builder.toString() );
+                log.info( builder.toString() );
+            }
+        }
+    }
+
+    /**
+     * Generate audit trail logging message
+     *
+     * @param userName   : Current user name
+     * @param action     : user's action ( add, edit, delete )
+     * @param objectType : The name of the object that user is working on
+     * @param objectName : The value of the name attribute of the object that
+     *                   user is working on
+     * @return : the audit trail logging message
+     */
+    public static String logMessage( String userName, String action, String objectType, String objectName )
+    {
+        return "'" + userName + "' " + action + " " + objectType + " '" + objectName + "'";
+    }
+}

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2012-07-01 18:55:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java	2012-11-25 18:27:00 +0000
@@ -48,7 +48,6 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.system.util.AuditLogUtil;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.user.CurrentUserService;
@@ -103,8 +102,8 @@
 
     public int addDataSet( DataSet dataSet )
     {
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_ADD, DataSet.class.getSimpleName(), dataSet.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+        //    AuditLogUtil.ACTION_CREATE, DataSet.class.getSimpleName(), dataSet.getName() ) );
 
         return dataSetStore.save( dataSet );
     }
@@ -113,14 +112,14 @@
     {
         dataSetStore.update( dataSet );
 
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_EDIT, DataSet.class.getSimpleName(), dataSet.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+        //    AuditLogUtil.ACTION_UPDATE, DataSet.class.getSimpleName(), dataSet.getName() ) );
     }
 
     public void deleteDataSet( DataSet dataSet )
     {
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
-            AuditLogUtil.ACTION_DELETE, DataSet.class.getSimpleName(), dataSet.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(),
+        //    AuditLogUtil.ACTION_DELETE, DataSet.class.getSimpleName(), dataSet.getName() ) );
         
         dataSetStore.delete( dataSet );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2012-10-31 17:24:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2012-11-25 18:27:00 +0000
@@ -33,7 +33,6 @@
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.hierarchy.HierarchyViolationException;
 import org.hisp.dhis.organisationunit.comparator.OrganisationUnitLevelComparator;
-import org.hisp.dhis.system.util.AuditLogUtil;
 import org.hisp.dhis.system.util.ConversionUtils;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
@@ -105,8 +104,8 @@
             currentUserService.getCurrentUser().getOrganisationUnits().add( organisationUnit );
         }
 
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_ADD,
-            OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_CREATE,
+        //    OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
 
         updateVersion();
 
@@ -117,8 +116,8 @@
     {
         organisationUnitStore.update( organisationUnit );
 
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_EDIT,
-            OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_UPDATE,
+        //    OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
 
         updateVersion();
     }
@@ -147,8 +146,8 @@
             organisationUnitStore.update( parent );
         }
 
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_DELETE,
-            OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
+        //log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_DELETE,
+        //    OrganisationUnit.class.getSimpleName(), organisationUnit.getName() ) );
 
         organisationUnitStore.delete( organisationUnit );
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2012-11-08 09:46:51 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java	2012-11-25 18:27:00 +0000
@@ -37,7 +37,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.filter.UserCredentialsCanUpdateFilter;
-import org.hisp.dhis.system.util.AuditLogUtil;
+import org.hisp.dhis.common.AuditLogUtil;
 import org.hisp.dhis.system.util.Filter;
 import org.hisp.dhis.system.util.FilterUtils;
 import org.springframework.transaction.annotation.Transactional;
@@ -156,7 +156,7 @@
 
     public int addUser( User user )
     {
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_ADD, User.class
+        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_CREATE, User.class
             .getSimpleName(), user.getName() ) );
 
         return userStore.save( user );
@@ -166,7 +166,7 @@
     {
         userStore.update( user );
 
-        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_EDIT,
+        log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_UPDATE,
             User.class.getSimpleName(), user.getName() ) );
     }
 

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/pom.xml'
--- dhis-2/dhis-support/dhis-support-hibernate/pom.xml	2012-11-14 16:52:37 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/pom.xml	2012-11-25 18:27:00 +0000
@@ -1,22 +1,22 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0";
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
-  
+
   <parent>
     <groupId>org.hisp.dhis</groupId>
     <artifactId>dhis-support</artifactId>
     <version>2.11-SNAPSHOT</version>
   </parent>
-  
+
   <artifactId>dhis-support-hibernate</artifactId>
   <packaging>jar</packaging>
   <name>DHIS Hibernate Support</name>
-  
+
   <dependencies>
-    
+
     <!-- DHIS -->
-    
+
     <dependency>
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-api</artifactId>
@@ -25,9 +25,9 @@
       <groupId>org.hisp.dhis</groupId>
       <artifactId>dhis-support-external</artifactId>
     </dependency>
-    
+
     <!-- Hibernate -->
-    
+
     <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-core</artifactId>
@@ -48,28 +48,28 @@
       <groupId>c3p0</groupId>
       <artifactId>c3p0</artifactId>
     </dependency>
-	<dependency>
-	  <groupId>cglib</groupId>
-	  <artifactId>cglib</artifactId>
-	</dependency>
-    
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib</artifactId>
+    </dependency>
+
     <!-- Database connectors -->
-    
+
     <dependency>
       <groupId>mysql</groupId>
       <artifactId>mysql-connector-java</artifactId>
     </dependency>
     <dependency>
-	  <groupId>postgresql</groupId>
-	  <artifactId>postgresql</artifactId>
-	</dependency>
+      <groupId>postgresql</groupId>
+      <artifactId>postgresql</artifactId>
+    </dependency>
     <dependency>
       <groupId>com.h2database</groupId>
       <artifactId>h2</artifactId>
     </dependency>
-    
+
     <!-- Other -->
-    
+
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-orm</artifactId>
@@ -77,8 +77,8 @@
     <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging</artifactId>
-    </dependency> 
-    
+    </dependency>
+
   </dependencies>
   <properties>
     <rootDir>../../</rootDir>

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2012-10-26 15:53:06 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2012-11-25 18:27:00 +0000
@@ -27,11 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hibernate.Criteria;
 import org.hibernate.Query;
 import org.hibernate.SQLQuery;
@@ -40,11 +37,19 @@
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.common.AuditLogUtil;
 import org.hisp.dhis.common.GenericNameableObjectStore;
+import org.hisp.dhis.user.CurrentUserService;
 import org.hisp.dhis.user.User;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Required;
 import org.springframework.jdbc.core.JdbcTemplate;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -52,6 +57,8 @@
 public class HibernateGenericStore<T>
     implements GenericNameableObjectStore<T>
 {
+    private static final Log log = LogFactory.getLog( HibernateGenericStore.class );
+
     protected SessionFactory sessionFactory;
 
     @Required
@@ -67,6 +74,9 @@
         this.jdbcTemplate = jdbcTemplate;
     }
 
+    @Autowired
+    private CurrentUserService currentUserService;
+
     private Class<T> clazz;
 
     /**
@@ -133,7 +143,7 @@
     }
 
     /**
-     * Creates a Critera for the implementation Class type.
+     * Creates a Criteria for the implementation Class type.
      *
      * @return a Criteria instance.
      */
@@ -197,18 +207,22 @@
     @Override
     public int save( T object )
     {
+        AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_CREATE );
         return (Integer) sessionFactory.getCurrentSession().save( object );
     }
 
     @Override
     public void update( T object )
     {
+        AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_UPDATE );
         sessionFactory.getCurrentSession().update( object );
     }
 
     @Override
     public void saveOrUpdate( T object )
     {
+        // TODO check if object is persisted or not to decide logging? defaulting to edit for now
+        AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_UPDATE );
         sessionFactory.getCurrentSession().saveOrUpdate( object );
     }
 
@@ -216,38 +230,56 @@
     @SuppressWarnings( "unchecked" )
     public final T get( int id )
     {
-        return (T) sessionFactory.getCurrentSession().get( getClazz(), id );
+        T object = (T) sessionFactory.getCurrentSession().get( getClazz(), id );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
 
     @Override
     @SuppressWarnings( "unchecked" )
     public final T load( int id )
     {
-        return (T) sessionFactory.getCurrentSession().load( getClazz(), id );
+        T object = (T) sessionFactory.getCurrentSession().load( getClazz(), id );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
-    
+
     @Override
     public final T getByUid( String uid )
     {
-        return getObject( Restrictions.eq( "uid", uid ) );
+        T object = getObject( Restrictions.eq( "uid", uid ) );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
 
     @Override
     public final T getByName( String name )
     {
-        return getObject( Restrictions.eq( "name", name ) );
+        T object = getObject( Restrictions.eq( "name", name ) );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
 
     @Override
     public final T getByShortName( String shortName )
     {
-        return getObject( Restrictions.eq( "shortName", shortName ) );
+        T object = getObject( Restrictions.eq( "shortName", shortName ) );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
 
     @Override
     public final T getByCode( String code )
     {
-        return getObject( Restrictions.eq( "code", code ) );
+        T object = getObject( Restrictions.eq( "code", code ) );
+        // AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_READ );
+
+        return object;
     }
 
     @Override
@@ -366,8 +398,8 @@
     @Override
     public long getCountByLastUpdated( Date lastUpdated )
     {
-        Object count  = getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).setProjection( Projections.rowCount() ).list().get( 0 );
-        
+        Object count = getCriteria().add( Restrictions.ge( "lastUpdated", lastUpdated ) ).setProjection( Projections.rowCount() ).list().get( 0 );
+
         return count != null ? (Long) count : -1;
     }
 
@@ -379,11 +411,11 @@
     }
 
     @Override
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public List<T> getAccessibleByUser( User user )
     {
         //TODO link to interface
-        
+
         Criteria criteria = getCriteria();
         criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
         criteria.addOrder( Order.asc( "name" ) );

=== removed file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogUtil.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogUtil.java	2012-11-23 13:15:51 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AuditLogUtil.java	1970-01-01 00:00:00 +0000
@@ -1,50 +0,0 @@
-package org.hisp.dhis.system.util;
-
-/*
- * Copyright (c) 2004-2012, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright notice, this
- *   list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright notice,
- *   this list of conditions and the following disclaimer in the documentation
- *   and/or other materials provided with the distribution.
- * * Neither the name of the HISP project nor the names of its contributors may
- *   be used to endorse or promote products derived from this software without
- *   specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-public class AuditLogUtil
-{
-    public static final String ACTION_ADD = "added";
-    public static final String ACTION_EDIT = "edited";
-    public static final String ACTION_DELETE = "deleted";
-
-    /**
-     * Generate audit trail logging message
-     * 
-     * @param userName : Current user name
-     * @param action : user's action ( add, edit, delete )
-     * @param objectType : The name of the object that user is working on
-     * @param objectName : The value of the name attribute of the object that
-     *        user is working on
-     * @return : the audit trail logging message
-     */
-    public static String logMessage( String userName, String action, String objectType, String objectName )
-    {
-        return "'" + userName + "' " + action + " " + objectType + " '" + objectName + "'";
-    }
-}

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2012-10-31 08:03:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AbstractCrudController.java	2012-11-25 18:27:00 +0000
@@ -63,7 +63,7 @@
 
     @Autowired
     protected IdentifiableObjectManager manager;
-    
+
     //--------------------------------------------------------------------------
     // GET
     //--------------------------------------------------------------------------
@@ -109,7 +109,7 @@
     }
 
     @RequestMapping( value = "/{uid}", method = RequestMethod.GET )
-    public String getObject( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters, 
+    public String getObject( @PathVariable( "uid" ) String uid, @RequestParam Map<String, String> parameters,
         Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         WebOptions options = new WebOptions( parameters );
@@ -120,7 +120,7 @@
             ContextUtils.notFoundResponse( response, "Object not found for uid: " + uid );
             return null;
         }
-        
+
         if ( options.hasLinks() )
         {
             WebUtils.generateLinks( entity );
@@ -136,7 +136,7 @@
     }
 
     @RequestMapping( value = "/search/{query}", method = RequestMethod.GET )
-    public String search( @PathVariable String query, @RequestParam Map<String, String> parameters, 
+    public String search( @PathVariable String query, @RequestParam Map<String, String> parameters,
         Model model, HttpServletRequest request, HttpServletResponse response ) throws Exception
     {
         WebOptions options = new WebOptions( parameters );
@@ -147,7 +147,7 @@
             ContextUtils.notFoundResponse( response, "Object not found for query: " + query );
             return null;
         }
-        
+
         if ( options.hasLinks() )
         {
             WebUtils.generateLinks( entity );
@@ -217,7 +217,7 @@
     //--------------------------------------------------------------------------
 
     /**
-     * Override to process a single entity after it has been retrieved from 
+     * Override to process a single entity after it has been retrieved from
      * storage and before it is returned to the view. Entity is null-safe.
      */
     public void postProcessEntity( T entity ) throws Exception
@@ -225,7 +225,7 @@
     }
 
     /**
-     * Override to process a single entity after it has been retrieved from 
+     * Override to process a single entity after it has been retrieved from
      * storage and before it is returned to the view. Entity is null-safe.
      */
     public void postProcessEntity( T entity, Map<String, String> parameters ) throws Exception