From 59b797c8fcc932b13b7c7452a6ee9bd8a2cd101c Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Tue, 31 Aug 2010 20:05:41 +0000 Subject: [PATCH] ALF-4106: Added entry deletion count return value for clear() git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22109 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../java/org/alfresco/repo/audit/AuditComponent.java | 3 ++- .../org/alfresco/repo/audit/AuditComponentImpl.java | 11 +++++++---- .../org/alfresco/repo/audit/AuditServiceImpl.java | 8 ++++---- .../java/org/alfresco/repo/domain/audit/AuditDAO.java | 3 ++- .../repo/domain/audit/ibatis/AuditDAOImpl.java | 4 ++-- .../org/alfresco/service/cmr/audit/AuditService.java | 6 ++++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/source/java/org/alfresco/repo/audit/AuditComponent.java b/source/java/org/alfresco/repo/audit/AuditComponent.java index 164fa37f08..b6c6123f7c 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponent.java +++ b/source/java/org/alfresco/repo/audit/AuditComponent.java @@ -78,10 +78,11 @@ public interface AuditComponent * @param applicationName the name of the application being logged to * @param fromTime the start time of entries to remove (inclusive and optional) * @param toTime the end time of entries to remove (exclusive and optional) + * @return Returns the number of entries deleted * * @since 3.2 */ - void deleteAuditEntries(String applicationName, Long fromTime, Long toTime); + int deleteAuditEntries(String applicationName, Long fromTime, Long toTime); /** * Check if an audit path is enabled. The path will be disabled if it or any higher diff --git a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java index 64a570339c..af2705058d 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java @@ -113,7 +113,7 @@ public class AuditComponentImpl implements AuditComponent * {@inheritDoc} * @since 3.2 */ - public void deleteAuditEntries(String applicationName, Long fromTime, Long toTime) + public int deleteAuditEntries(String applicationName, Long fromTime, Long toTime) { ParameterCheck.mandatory("applicationName", applicationName); AlfrescoTransactionSupport.checkTransactionReadState(true); @@ -125,17 +125,20 @@ public class AuditComponentImpl implements AuditComponent { logger.debug("No audit application named '" + applicationName + "' has been registered."); } - return; + return 0; } Long applicationId = application.getApplicationId(); - auditDAO.deleteAuditEntries(applicationId, fromTime, toTime); + int deleted = auditDAO.deleteAuditEntries(applicationId, fromTime, toTime); // Done if (logger.isDebugEnabled()) { - logger.debug("Delete audit entries for " + applicationName + " (" + fromTime + " to " + toTime); + logger.debug( + "Delete audit " + deleted + " entries for " + applicationName + + " (" + fromTime + " to " + toTime); } + return deleted; } /** diff --git a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java index 5f4d07d949..871001d070 100644 --- a/source/java/org/alfresco/repo/audit/AuditServiceImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditServiceImpl.java @@ -115,10 +115,10 @@ public class AuditServiceImpl implements AuditService * {@inheritDoc} * @since 3.2 */ - public void clearAudit(String applicationName) + public int clearAudit(String applicationName) { Long now = Long.valueOf(System.currentTimeMillis()); - auditComponent.deleteAuditEntries(applicationName, null, now); + return auditComponent.deleteAuditEntries(applicationName, null, now); } /** @@ -126,10 +126,10 @@ public class AuditServiceImpl implements AuditService * @since 3.4 */ @Override - public void clearAudit(String applicationName, Long fromTime, Long toTime) + public int clearAudit(String applicationName, Long fromTime, Long toTime) { toTime = (toTime == null) ? Long.valueOf(System.currentTimeMillis()) : toTime; - auditComponent.deleteAuditEntries(applicationName, fromTime, toTime); + return auditComponent.deleteAuditEntries(applicationName, fromTime, toTime); } /** diff --git a/source/java/org/alfresco/repo/domain/audit/AuditDAO.java b/source/java/org/alfresco/repo/domain/audit/AuditDAO.java index a44a241ce0..afa2c7809c 100644 --- a/source/java/org/alfresco/repo/domain/audit/AuditDAO.java +++ b/source/java/org/alfresco/repo/domain/audit/AuditDAO.java @@ -160,10 +160,11 @@ public interface AuditDAO * @param applicationId and existing audit application ID * @param from the minimum entry time (inclusive, optional) * @param to the maximum entry time (exclusive, optional) + * @return Returns the number of entries deleted * * @since 3.2 */ - void deleteAuditEntries(Long applicationId, Long from, Long to); + int deleteAuditEntries(Long applicationId, Long from, Long to); /** * Create a new audit entry with the given map of values. diff --git a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java index 03746873b4..0fd0b5c1e8 100644 --- a/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/audit/ibatis/AuditDAOImpl.java @@ -161,13 +161,13 @@ public class AuditDAOImpl extends AbstractAuditDAOImpl return updateEntity; } - public void deleteAuditEntries(Long applicationId, Long from, Long to) + public int deleteAuditEntries(Long applicationId, Long from, Long to) { AuditDeleteParameters params = new AuditDeleteParameters(); params.setAuditApplicationId(applicationId); params.setAuditFromTime(from); params.setAuditToTime(to); - template.delete(DELETE_ENTRIES, params); + return template.delete(DELETE_ENTRIES, params); } @Override diff --git a/source/java/org/alfresco/service/cmr/audit/AuditService.java b/source/java/org/alfresco/service/cmr/audit/AuditService.java index ea4c830898..cb4f12b9cd 100644 --- a/source/java/org/alfresco/service/cmr/audit/AuditService.java +++ b/source/java/org/alfresco/service/cmr/audit/AuditService.java @@ -123,12 +123,13 @@ public interface AuditService * Remove all audit entries for the given application * * @param applicationName the name of the application for which to remove entries + * @return Returns the number of audit entries deleted * * @since 3.2 * * @deprecated Use {@link #clearAudit(String, Long, Long)} */ - void clearAudit(String applicationName); + int clearAudit(String applicationName); /** * Remove audit entries for the given application between the time ranges. If no start @@ -138,10 +139,11 @@ public interface AuditService * @param applicationName the name of the application for which to remove entries * @param fromTime the start time of entries to remove (inclusive and optional) * @param toTime the end time of entries to remove (exclusive and optional) + * @return Returns the number of audit entries deleted * * @since 3.4 */ - void clearAudit(String applicationName, Long fromTime, Long toTime); + int clearAudit(String applicationName, Long fromTime, Long toTime); /** * The interface that will be used to give query results to the calling code.