dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20690
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9589: Added user in maintenance logging
------------------------------------------------------------
revno: 9589
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-01-23 12:54:42 +0100
message:
Added user in maintenance logging
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
--
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
=== modified 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 2013-01-09 12:03:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/AuditLogUtil.java 2013-01-23 11:54:42 +0000
@@ -50,43 +50,21 @@
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() );
+ builder.append( "'" ).append( username ).append( "' " ).append( action );
+ builder.append( " " ).append( object.getClass().getName() );
if ( idObject.getName() != null && !idObject.getName().isEmpty() )
{
- builder.append( ", name: " );
- builder.append( idObject.getName() );
+ builder.append( ", name: " ).append( idObject.getName() );
}
if ( idObject.getUid() != null && !idObject.getUid().isEmpty() )
{
- builder.append( ", uid: " );
- builder.append( idObject.getUid() );
+ builder.append( ", uid: " ).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/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-01-14 21:35:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-01-23 11:54:42 +0000
@@ -28,16 +28,20 @@
*/
import java.io.Serializable;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.common.AuditLogUtil;
import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.system.filter.UserCredentialsCanUpdateFilter;
-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,8 +160,7 @@
public int addUser( User user )
{
- log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_CREATE, User.class
- .getSimpleName(), user.getName() ) );
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), user, AuditLogUtil.ACTION_CREATE );
return userStore.save( user );
}
@@ -166,15 +169,13 @@
{
userStore.update( user );
- log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_UPDATE,
- User.class.getSimpleName(), user.getName() ) );
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), user, AuditLogUtil.ACTION_UPDATE );
}
public void deleteUser( User user )
{
- log.info( AuditLogUtil.logMessage( currentUserService.getCurrentUsername(), AuditLogUtil.ACTION_DELETE,
- User.class.getSimpleName(), user.getName() ) );
-
+ AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), user, AuditLogUtil.ACTION_DELETE );
+
userStore.delete( user );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2012-07-26 20:37:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/maintenance/PerformMaintenanceAction.java 2013-01-23 11:54:42 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.maintenance.MaintenanceService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
+import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -95,6 +96,13 @@
this.periodService = periodService;
}
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -149,7 +157,7 @@
aggregatedOrgUnitDataValueService.deleteAggregatedDataValues();
aggregatedOrgUnitDataValueService.deleteAggregatedIndicatorValues();
- log.info( "Cleared data mart" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Cleared data mart" );
}
if ( dataMartIndex )
@@ -167,7 +175,7 @@
completenessService.dropIndex();
completenessService.createIndex();
- log.info( "Rebuilt data mart indexes" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Rebuilt data mart indexes" );
}
if ( zeroValues )
@@ -181,12 +189,14 @@
{
completenessService.deleteDataSetCompleteness();
- log.info( "Cleared data completeness" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Cleared data completeness" );
}
if ( prunePeriods )
{
prunePeriods();
+
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Pruned periods" );
}
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2012-12-27 18:15:23 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/resourcetable/GenerateResourceTableAction.java 2013-01-23 11:54:42 +0000
@@ -31,6 +31,7 @@
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.resourcetable.ResourceTableService;
import org.hisp.dhis.sqlview.SqlViewService;
+import org.hisp.dhis.user.CurrentUserService;
import com.opensymphony.xwork2.Action;
@@ -121,6 +122,13 @@
this.periodStructure = periodStructure;
}
+ private CurrentUserService currentUserService;
+
+ public void setCurrentUserService( CurrentUserService currentUserService )
+ {
+ this.currentUserService = currentUserService;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -130,7 +138,7 @@
{
sqlViewService.dropAllSqlViewTables();
- log.info( "Dropped all sql views" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Dropped all sql views" );
if ( organisationUnit )
{
@@ -172,11 +180,11 @@
resourceTableService.generatePeriodTable();
}
- log.info( "Generated resource tables" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Generated resource tables" );
sqlViewService.createAllViewTables();
- log.info( "Created all views" );
+ log.info( "'" + currentUserService.getCurrentUsername() + "': Created all views" );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2012-12-14 13:46:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2013-01-23 11:54:42 +0000
@@ -14,6 +14,7 @@
<property name="aggregatedOrgUnitDataValueService" ref="org.hisp.dhis.aggregation.AggregatedOrgUnitDataValueService" />
<property name="dataMartManager" ref="org.hisp.dhis.datamart.DataMartManager" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<!-- Resource table -->
@@ -22,7 +23,8 @@
class="org.hisp.dhis.dataadmin.action.resourcetable.GenerateResourceTableAction"
scope="prototype">
<property name="resourceTableService" ref="org.hisp.dhis.resourcetable.ResourceTableService" />
- <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
+ <property name="sqlViewService" ref="org.hisp.dhis.sqlview.SqlViewService" />
+ <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
</bean>
<!-- Cache -->