mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Added 'enableAuditPath' and 'disableAuditPath'
- Various tests to see that the recorded data is changed - disabledPaths rely entirely on the property caching for fast retrieval git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16271 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -62,6 +62,8 @@ public class AuditApplication
|
||||
private final Map<String, DataGenerator> dataGeneratorsByName;
|
||||
@SuppressWarnings("unused")
|
||||
private final Application application;
|
||||
private final Long applicationId;
|
||||
private final Long disabledPathsId;
|
||||
|
||||
/** Derived expaned map for fast lookup */
|
||||
private Map<String, Map<String, DataExtractor>> dataExtractors = new HashMap<String, Map<String, DataExtractor>>(11);
|
||||
@@ -76,7 +78,9 @@ public class AuditApplication
|
||||
/* package */ AuditApplication(
|
||||
Map<String, DataExtractor> dataExtractorsByName,
|
||||
Map<String, DataGenerator> dataGeneratorsByName,
|
||||
Application application)
|
||||
Application application,
|
||||
Long applicationId,
|
||||
Long disabledPathsId)
|
||||
{
|
||||
this.dataExtractorsByName = dataExtractorsByName;
|
||||
this.dataGeneratorsByName = dataGeneratorsByName;
|
||||
@@ -84,6 +88,8 @@ public class AuditApplication
|
||||
|
||||
this.applicationName = application.getName();
|
||||
this.applicationKey = application.getKey();
|
||||
this.applicationId = applicationId;
|
||||
this.disabledPathsId = disabledPathsId;
|
||||
|
||||
buildAuditPaths(application);
|
||||
}
|
||||
@@ -118,6 +124,8 @@ public class AuditApplication
|
||||
StringBuilder sb = new StringBuilder(56);
|
||||
sb.append("AuditApplication")
|
||||
.append("[ name=").append(applicationName)
|
||||
.append(", id=").append(applicationId)
|
||||
.append(", disabledPathsId=").append(disabledPathsId)
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
@@ -138,6 +146,24 @@ public class AuditApplication
|
||||
return applicationKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the database ID for this application
|
||||
*/
|
||||
public Long getApplicationId()
|
||||
{
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the property representing the set of disabled paths for the application
|
||||
*
|
||||
* @return Returns an ID <code>Set<String></code> of disabled paths
|
||||
*/
|
||||
public Long getDisabledPathsId()
|
||||
{
|
||||
return disabledPathsId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to check that a path is correct for this application instance
|
||||
*
|
||||
|
@@ -96,14 +96,6 @@ public class AuditModelRegistry
|
||||
* Used to lookup the audit application java hierarchy
|
||||
*/
|
||||
private final Map<String, AuditApplication> auditApplicationsByName;
|
||||
/**
|
||||
* Used to lookup a reference to the application
|
||||
*/
|
||||
private final Map<String, Long> auditApplicationIdsByApplicationsName;
|
||||
/**
|
||||
* Used to lookup application disabled paths
|
||||
*/
|
||||
private final Map<String, Set<String>> auditDisabledPathsByApplicationsName;
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
@@ -119,8 +111,6 @@ public class AuditModelRegistry
|
||||
auditModelUrls = new HashSet<URL>(7);
|
||||
auditModels = new ArrayList<Audit>(7);
|
||||
auditApplicationsByName = new HashMap<String, AuditApplication>(7);
|
||||
auditApplicationIdsByApplicationsName = new HashMap<String, Long>(7);
|
||||
auditDisabledPathsByApplicationsName = new HashMap<String, Set<String>>(7);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +205,6 @@ public class AuditModelRegistry
|
||||
{
|
||||
auditModels.clear();
|
||||
auditApplicationsByName.clear();
|
||||
auditApplicationIdsByApplicationsName.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +212,8 @@ public class AuditModelRegistry
|
||||
* the audit models for later retrieval. Models are loaded from the locations given by the
|
||||
* {@link #registerModel(URL) register} methods.
|
||||
* <p/>
|
||||
* Note, the models are loaded in a new transaction.
|
||||
* Note, the models are loaded in a new transaction, so this method can be called by any code
|
||||
* at any time.
|
||||
*/
|
||||
public void loadAuditModels()
|
||||
{
|
||||
@@ -268,7 +258,7 @@ public class AuditModelRegistry
|
||||
clearCaches();
|
||||
try
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(loadModelsCallback);
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(loadModelsCallback, false, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -276,25 +266,6 @@ public class AuditModelRegistry
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of the persisted audit application for the given application name
|
||||
*
|
||||
* @param applicationName the name of the audited application
|
||||
* @return the unique ID of the persisted application (<tt>null</tt> if not found)
|
||||
*/
|
||||
public Long getAuditApplicationId(String applicationName)
|
||||
{
|
||||
readLock.lock();
|
||||
try
|
||||
{
|
||||
return auditApplicationIdsByApplicationsName.get(applicationName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the application model for the given application name
|
||||
*
|
||||
@@ -314,25 +285,6 @@ public class AuditModelRegistry
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all disabled paths for the given application name
|
||||
*
|
||||
* @param applicationName the name of the audited application
|
||||
* @return a set of paths for which logging is disabled
|
||||
*/
|
||||
public Set<String> getAuditDisabledPaths(String applicationName)
|
||||
{
|
||||
readLock.lock();
|
||||
try
|
||||
{
|
||||
return auditDisabledPathsByApplicationsName.get(applicationName);
|
||||
}
|
||||
finally
|
||||
{
|
||||
readLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshalls the Audit model from the URL.
|
||||
*
|
||||
@@ -552,10 +504,13 @@ public class AuditModelRegistry
|
||||
auditDAO.updateAuditApplicationModel(appInfo.getId(), auditModelId);
|
||||
}
|
||||
|
||||
AuditApplication wrapperApp = new AuditApplication(dataExtractorsByName, dataGeneratorsByName, application);
|
||||
AuditApplication wrapperApp = new AuditApplication(
|
||||
dataExtractorsByName,
|
||||
dataGeneratorsByName,
|
||||
application,
|
||||
appInfo.getId(),
|
||||
appInfo.getDisabledPathsId());
|
||||
auditApplicationsByName.put(name, wrapperApp);
|
||||
auditApplicationIdsByApplicationsName.put(name, appInfo.getId());
|
||||
auditDisabledPathsByApplicationsName.put(name, appInfo.getDisabledPaths());
|
||||
}
|
||||
// Store the model itself
|
||||
auditModels.add(audit);
|
||||
|
Reference in New Issue
Block a user