mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged 5.2.N-AUDIT-API (5.2.2) to 5.2.N (5.2.2)
137955 jvonka: REPO-2643 - add "clearAuditByIdRange" to underlying Audit Service/Component/DAO - to enable deletion of audit entries within an audit app based on id range (fromId / toId) in addition to time range - required for REST API Delete Application Audit Entries (REPO-1519) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@137982 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -148,21 +148,12 @@ public class AuditComponentImpl implements AuditComponent
|
||||
*/
|
||||
public int deleteAuditEntries(String applicationName, Long fromTime, Long toTime)
|
||||
{
|
||||
ParameterCheck.mandatory("applicationName", applicationName);
|
||||
AlfrescoTransactionSupport.checkTransactionReadState(true);
|
||||
|
||||
AuditApplication application = auditModelRegistry.getAuditApplicationByName(applicationName);
|
||||
if (application == null)
|
||||
Long applicationId = getApplicationId(applicationName);
|
||||
if (applicationId == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No audit application named '" + applicationName + "' has been registered.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Long applicationId = application.getApplicationId();
|
||||
|
||||
|
||||
int deleted = auditDAO.deleteAuditEntries(applicationId, fromTime, toTime);
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -174,6 +165,47 @@ public class AuditComponentImpl implements AuditComponent
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 5.2.2
|
||||
*/
|
||||
public int deleteAuditEntriesByIdRange(String applicationName, Long fromId, Long toId)
|
||||
{
|
||||
Long applicationId = getApplicationId(applicationName);
|
||||
if (applicationId == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int deleted = auditDAO.deleteAuditEntriesByIdRange(applicationId, fromId, toId);
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(
|
||||
"Delete audit " + deleted + " entries for " + applicationName +
|
||||
" (" + fromId + " to " + toId);
|
||||
}
|
||||
return deleted;
|
||||
}
|
||||
|
||||
private Long getApplicationId(String applicationName)
|
||||
{
|
||||
ParameterCheck.mandatory("applicationName", applicationName);
|
||||
AlfrescoTransactionSupport.checkTransactionReadState(true);
|
||||
|
||||
AuditApplication application = auditModelRegistry.getAuditApplicationByName(applicationName);
|
||||
if (application == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No audit application named '" + applicationName + "' has been registered.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return application.getApplicationId();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 3.2
|
||||
|
Reference in New Issue
Block a user