mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Audit changes and fixes
- Removed notion of audit session - Removed 'scope' attribute for DataGenerator elements - Removed alf_audit_session table and replaced with alf_audit_app (see script) - DataGenerators are working properly git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16053 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -56,7 +56,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
*/
|
||||
public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(AbstractAuditDAOImpl.class);
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private HibernateAuditDAO oldDAO;
|
||||
private ContentService contentService;
|
||||
@@ -83,6 +83,11 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
this.propertyValueDAO = propertyValueDAO;
|
||||
}
|
||||
|
||||
protected PropertyValueDAO getPropertyValueDAO()
|
||||
{
|
||||
return this.propertyValueDAO;
|
||||
}
|
||||
|
||||
/*
|
||||
* Support for older audit DAO
|
||||
*/
|
||||
@@ -196,34 +201,42 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
protected abstract AuditModelEntity createAuditModel(Long contentDataId, long crc);
|
||||
|
||||
/*
|
||||
* alf_audit_session
|
||||
* alf_audit_application
|
||||
*/
|
||||
|
||||
public Long createAuditSession(Long modelId, String application)
|
||||
|
||||
public Long getOrCreateAuditApplication(Long modelId, String application)
|
||||
{
|
||||
// Persist the string
|
||||
Long appNameId = propertyValueDAO.getOrCreatePropertyValue(application).getFirst();
|
||||
// Create the audit session
|
||||
AuditSessionEntity entity = createAuditSession(appNameId, modelId);
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
// Search for it
|
||||
AuditApplicationEntity entity = getAuditApplicationByModelIdAndName(modelId, application);
|
||||
if (entity == null)
|
||||
{
|
||||
logger.debug(
|
||||
"Created new audit session: \n" +
|
||||
" Model: " + modelId + "\n" +
|
||||
" App: " + application + "\n" +
|
||||
" Result: " + entity);
|
||||
// Create it
|
||||
// Persist the string
|
||||
Long appNameId = propertyValueDAO.getOrCreatePropertyValue(application).getFirst();
|
||||
// Create the audit session
|
||||
entity = createAuditApplication(modelId, appNameId);
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(
|
||||
"Created new audit application: \n" +
|
||||
" Model: " + modelId + "\n" +
|
||||
" App: " + application + "\n" +
|
||||
" Result: " + entity);
|
||||
}
|
||||
}
|
||||
// Done
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
protected abstract AuditSessionEntity createAuditSession(Long appNameId, Long modelId);
|
||||
|
||||
protected abstract AuditApplicationEntity getAuditApplicationByModelIdAndName(Long modelId, String appName);
|
||||
protected abstract AuditApplicationEntity createAuditApplication(Long modelId, Long appNameId);
|
||||
|
||||
/*
|
||||
* alf_audit_entry
|
||||
*/
|
||||
|
||||
public Long createAuditEntry(Long sessionId, long time, String username, Map<String, Serializable> values)
|
||||
public Long createAuditEntry(Long applicationId, long time, String username, Map<String, Serializable> values)
|
||||
{
|
||||
final Long usernameId;
|
||||
if (username != null)
|
||||
@@ -242,20 +255,20 @@ public abstract class AbstractAuditDAOImpl implements AuditDAO
|
||||
}
|
||||
|
||||
// Create the audit entry
|
||||
AuditEntryEntity entity = createAuditEntry(sessionId, time, usernameId, valuesId);
|
||||
AuditEntryEntity entity = createAuditEntry(applicationId, time, usernameId, valuesId);
|
||||
|
||||
// Done
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(
|
||||
"Created new audit entry: \n" +
|
||||
" Session: " + sessionId + "\n" +
|
||||
" Time: " + (new Date(time)) + "\n" +
|
||||
" User: " + username + "\n" +
|
||||
" Result: " + entity);
|
||||
" Application: " + applicationId + "\n" +
|
||||
" Time: " + (new Date(time)) + "\n" +
|
||||
" User: " + username + "\n" +
|
||||
" Result: " + entity);
|
||||
}
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
protected abstract AuditEntryEntity createAuditEntry(Long sessionId, long time, Long usernameId, Long valuesId);
|
||||
protected abstract AuditEntryEntity createAuditEntry(Long applicationId, long time, Long usernameId, Long valuesId);
|
||||
}
|
||||
|
Reference in New Issue
Block a user