From 62c7b53c798ecbd37295359870e3154c40b003ad Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Mon, 6 Oct 2008 10:25:07 +0000 Subject: [PATCH] Merged V2.2 to HEAD 10951: Merged V2.1 to V2.2 10473: Fixed for ETWOONE-114 and ETWOONE-125 10873: Added missing SQL patch reference for post-schema-update tasks: patch.db-V2.1-AuditPathIndex Build label changed to 3.0.0c Labs git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11200 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/audit-services-context.xml | 6 + config/alfresco/bootstrap-context.xml | 2 + .../post-create-indexes-04.sql | 12 ++ .../post-create-indexes-04.sql | 12 ++ ...lfrescoSchemaUpdate-2.1-AuditPathIndex.sql | 23 ++++ ...lfrescoSchemaUpdate-2.1-AuditPathIndex.sql | 23 ++++ .../alfresco/patch/patch-services-context.xml | 11 ++ config/alfresco/version.properties | 5 +- .../repo/audit/AuditComponentImpl.java | 87 +++++++++++++- .../repo/audit/model/AbstractAuditEntry.java | 46 ++++++++ .../audit/model/ApplicationAuditEntry.java | 2 +- .../alfresco/repo/audit/model/AuditEntry.java | 107 +++++++++++++----- .../repo/audit/model/MethodAuditEntry.java | 5 +- .../repo/audit/model/ServiceAuditEntry.java | 28 +++-- 14 files changed, 318 insertions(+), 51 deletions(-) create mode 100644 config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.Dialect/post-create-indexes-04.sql create mode 100644 config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.MySQLInnoDBDialect/post-create-indexes-04.sql create mode 100644 config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql create mode 100644 config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql diff --git a/config/alfresco/audit-services-context.xml b/config/alfresco/audit-services-context.xml index 2b889fa114..57b937343f 100644 --- a/config/alfresco/audit-services-context.xml +++ b/config/alfresco/audit-services-context.xml @@ -24,6 +24,12 @@ + + + + + + diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index c35d1cf720..5a1a605d7a 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -49,6 +49,7 @@ classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-MappedFKIndexes.sql classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-Extra.sql + classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/post-create-indexes-04.sql classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-extras.sql @@ -78,6 +79,7 @@ + diff --git a/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.Dialect/post-create-indexes-04.sql b/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.Dialect/post-create-indexes-04.sql new file mode 100644 index 0000000000..e7ce879199 --- /dev/null +++ b/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.Dialect/post-create-indexes-04.sql @@ -0,0 +1,12 @@ +-- +-- Title: Audit Path index +-- Database: Generic +-- Since: V2.1 Schema 81 +-- Author: Andy Hind +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- Audit path index + + +CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path); diff --git a/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.MySQLInnoDBDialect/post-create-indexes-04.sql b/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.MySQLInnoDBDialect/post-create-indexes-04.sql new file mode 100644 index 0000000000..2c63c5d7dd --- /dev/null +++ b/config/alfresco/dbscripts/create/2.2/org.hibernate.dialect.MySQLInnoDBDialect/post-create-indexes-04.sql @@ -0,0 +1,12 @@ +-- +-- Title: Audit Path index +-- Database: Generic +-- Since: V2.1 Schema 81 +-- Author: Andy Hind +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- Audit path index + + +CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path(128)); diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql new file mode 100644 index 0000000000..ead27ee036 --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.Dialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql @@ -0,0 +1,23 @@ +-- +-- Title: Ensure the audit table path column is indexed +-- Database: Generic +-- Since: V2.1 Schema 82 +-- Author: Andy Hind +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- Path was previously unused and unindex - new we use it the index is required. + +CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path); + +-- +-- Record script finish +-- +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-AuditPathIndex'; +INSERT INTO alf_applied_patch + (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) + VALUES + ( + 'patch.db-V2.1-AuditPathIndex', 'Manually executed script upgrade V2.1: Ensure existence of audit path index', + 0, 81, -1, 82, null, 'UNKOWN', 1, 1, 'Script completed' + ); \ No newline at end of file diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql new file mode 100644 index 0000000000..1f3600ac25 --- /dev/null +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql @@ -0,0 +1,23 @@ +-- +-- Title: Ensure the audit table path column is indexed +-- Database: Generic +-- Since: V2.1 Schema 82 +-- Author: Andy Hind +-- +-- Please contact support@alfresco.com if you need assistance with the upgrade. +-- +-- Path was previously unused and unindex - new we use it the index is required. + +CREATE INDEX idx_alf_adtf_pth ON alf_audit_fact (path(128)); + +-- +-- Record script finish +-- +DELETE FROM alf_applied_patch WHERE id = 'patch.db-V2.1-AuditPathIndex'; +INSERT INTO alf_applied_patch + (id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report) + VALUES + ( + 'patch.db-V2.1-AuditPathIndex', 'Manually executed script upgrade V2.1: Ensure existence of audit path index', + 0, 81, -1, 82, null, 'UNKOWN', 1, 1, 'Script completed' + ); \ No newline at end of file diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 71cbe0acfc..e0bac97291 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -1410,6 +1410,17 @@ + + + patch.db-V2.1-AuditPathIndex + patch.schemaUpgradeScript.description + 0 + 132 + 133 + + classpath:alfresco/dbscripts/upgrade/2.2/${db.script.dialect}/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql + + patch.db-V3.0-0-CreateActivitiesExtras diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index d852fa3014..30c5b72aaa 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -7,7 +7,7 @@ version.major=3 version.minor=0 version.revision=0 -version.label=b +version.label=c # Edition label @@ -19,4 +19,5 @@ version.build=@build-number@ # Schema number -version.schema=132 \ No newline at end of file +<<<<<<< .working +version.schema=133 diff --git a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java index 3060830b70..836e6e4b0d 100644 --- a/source/java/org/alfresco/repo/audit/AuditComponentImpl.java +++ b/source/java/org/alfresco/repo/audit/AuditComponentImpl.java @@ -35,6 +35,7 @@ import org.alfresco.repo.audit.model.AuditEntry; import org.alfresco.repo.audit.model.TrueFalseUnset; import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.transaction.AlfrescoTransactionSupport; +import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.service.Auditable; import org.alfresco.service.NotAuditable; @@ -42,8 +43,11 @@ import org.alfresco.service.PublicService; import org.alfresco.service.cmr.audit.AuditInfo; import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.cmr.repository.Path; import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.search.SearchParameters; +import org.alfresco.service.namespace.NamespacePrefixResolver; import org.alfresco.service.transaction.TransactionService; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; @@ -51,7 +55,7 @@ import org.apache.commons.logging.LogFactory; /** * The default audit component implementation. TODO: Implement before, after and exception filtering. At the moment - * these filters are ignired. TODO: Respect audit internal - at the moment audit internal is fixed to false. + * these filters are ignored. TODO: Respect audit internal - at the moment audit internal is fixed to false. * * @author Andy Hind */ @@ -82,7 +86,11 @@ public class AuditComponentImpl implements AuditComponent private AuditDAO auditDAO; private TransactionService transactionService; + + private NodeService nodeService; + private NamespacePrefixResolver namespacePrefixResolver; + private AuditModel auditModel; /** @@ -91,6 +99,8 @@ public class AuditComponentImpl implements AuditComponent private InetAddress auditHost; + + /** * Default constructor */ @@ -131,6 +141,16 @@ public class AuditComponentImpl implements AuditComponent { this.transactionService = transactionService; } + + /** + * Set the NodeService for path extracting. + * + * @param nodeService + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } /** * Set the audit configuration. @@ -162,6 +182,16 @@ public class AuditComponentImpl implements AuditComponent this.auditModel = auditModel; } + + /** + * Set the namespacePrefixResolver. + * @param namespacePrefixResolver + */ + public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver) + { + this.namespacePrefixResolver = namespacePrefixResolver; + } + public Object audit(MethodInvocation mi) throws Throwable { if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue())) @@ -280,7 +310,8 @@ public class AuditComponentImpl implements AuditComponent return null; } }; - transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, false); + boolean requiresNew = (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE); + transactionService.getRetryingTransactionHelper().doInTransaction(cb, false, requiresNew); } return o; } @@ -367,6 +398,11 @@ public class AuditComponentImpl implements AuditComponent NodeRef key = (NodeRef) returnObject; auditInfo.setKeyStore(key.getStoreRef()); auditInfo.setKeyGUID(key.getId()); + RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi); + if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE) + { + auditInfo.setPath(getNodePath(key)); + } } else if (returnObject instanceof StoreRef) { @@ -377,6 +413,11 @@ public class AuditComponentImpl implements AuditComponent ChildAssociationRef car = (ChildAssociationRef) returnObject; auditInfo.setKeyStore(car.getChildRef().getStoreRef()); auditInfo.setKeyGUID(car.getChildRef().getId()); + RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi); + if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE) + { + auditInfo.setPath(nodeService.getPath(car.getChildRef()).toString()); + } } else { @@ -423,6 +464,9 @@ public class AuditComponentImpl implements AuditComponent auditInfo.setFail(false); auditInfo.setFiltered(false); auditInfo.setHostAddress(auditHost); + + auditInfo.setPath(null); + Auditable auditable = mi.getMethod().getAnnotation(Auditable.class); Object key = null; switch (auditable.key()) @@ -473,10 +517,15 @@ public class AuditComponentImpl implements AuditComponent } if (key != null) { + RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi); if (key instanceof NodeRef) { auditInfo.setKeyStore(((NodeRef) key).getStoreRef()); auditInfo.setKeyGUID(((NodeRef) key).getId()); + if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE) + { + auditInfo.setPath(getNodePath((NodeRef) key)); + } } else if (key instanceof StoreRef) { @@ -487,6 +536,10 @@ public class AuditComponentImpl implements AuditComponent ChildAssociationRef car = (ChildAssociationRef) key; auditInfo.setKeyStore(car.getParentRef().getStoreRef()); auditInfo.setKeyGUID(car.getParentRef().getId()); + if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE) + { + auditInfo.setPath(getNodePath(car.getParentRef())); + } } else if (key instanceof SearchParameters) { @@ -532,7 +585,6 @@ public class AuditComponentImpl implements AuditComponent } auditInfo.setMethodArguments(serArgs); } - auditInfo.setPath(null); auditInfo.setReturnObject(null); auditInfo.setSessionId(null); auditInfo.setThrowable(null); @@ -557,7 +609,6 @@ public class AuditComponentImpl implements AuditComponent public void audit(String source, String description, NodeRef key, Object... args) { final AuditState auditInfo = new AuditState(auditConfiguration); - // RecordOptions recordOptions = auditModel.getAuditRecordOptions(mi); AuditMode auditMode = AuditMode.UNSET; try { @@ -610,7 +661,7 @@ public class AuditComponentImpl implements AuditComponent private AuditMode onApplicationAudit(AuditMode auditMode, AuditState auditInfo, String source, String description, NodeRef key, Object... args) { AuditMode effectiveAuditMode = auditModel.beforeExecution(auditMode, source, description, key, args); - + auditModel.getAuditRecordOptions(source); if (auditMode != AuditMode.NONE) { if (source.equals(SYSTEM_APPLICATION)) @@ -627,10 +678,16 @@ public class AuditComponentImpl implements AuditComponent auditInfo.setFail(false); auditInfo.setFiltered(false); auditInfo.setHostAddress(auditHost); + auditInfo.setPath(null); if (key != null) { auditInfo.setKeyStore(key.getStoreRef()); auditInfo.setKeyGUID(key.getId()); + RecordOptions recordOptions = auditModel.getAuditRecordOptions(source); + if (recordOptions != null && recordOptions.getRecordPath() == TrueFalseUnset.TRUE) + { + auditInfo.setPath(getNodePath(key)); + } } auditInfo.setKeyPropertiesAfter(null); auditInfo.setKeyPropertiesBefore(null); @@ -655,7 +712,6 @@ public class AuditComponentImpl implements AuditComponent } auditInfo.setMethodArguments(serArgs); } - auditInfo.setPath(null); auditInfo.setReturnObject(null); auditInfo.setSessionId(null); auditInfo.setThrowable(null); @@ -677,4 +733,23 @@ public class AuditComponentImpl implements AuditComponent return auditMode; } + + /** + * Returns human readable path for node. + * To improve performance may return simple toString() method of the path. + * + * @param nodeRef + * @return Human readable path for node + */ + private String getNodePath(NodeRef nodeRef) + { + String result = null; + if (nodeService.exists(nodeRef)) + { + Path path = nodeService.getPath(nodeRef); + return path.toPrefixString(namespacePrefixResolver); + } + return result; + } + } diff --git a/source/java/org/alfresco/repo/audit/model/AbstractAuditEntry.java b/source/java/org/alfresco/repo/audit/model/AbstractAuditEntry.java index 94f8629a80..1f4f8079da 100644 --- a/source/java/org/alfresco/repo/audit/model/AbstractAuditEntry.java +++ b/source/java/org/alfresco/repo/audit/model/AbstractAuditEntry.java @@ -25,6 +25,7 @@ package org.alfresco.repo.audit.model; import org.alfresco.repo.audit.AuditMode; import org.alfresco.repo.audit.AuditModel; import org.alfresco.repo.audit.PublicServiceIdentifier; +import org.alfresco.repo.audit.RecordOptions; import org.alfresco.service.namespace.NamespacePrefixResolver; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -240,6 +241,51 @@ public abstract class AbstractAuditEntry } + protected RecordOptions getEffectiveRecordOptions() + { + RecordOptions recordOptions; + if (checkEnabled() == TrueFalseUnset.TRUE) + { + recordOptions = getRecordOptionsOrParentRecordOptions(); + } + else + { + recordOptions = null; + } + if(s_logger.isDebugEnabled()) + { + s_logger.debug("...Record Options = "+recordOptions); + } + return recordOptions; + } + + private RecordOptions getRecordOptionsOrParentRecordOptions() + { + RecordOptions recordOptions = getRecordOptions(); + if(s_logger.isDebugEnabled()) + { + s_logger.debug("... ... record options = "+recordOptions); + } + if (recordOptions == null) + { + if (getParent() == null) + { + return null; + } + else + { + return getParent().getRecordOptionsOrParentRecordOptions(); + } + } + else + { + return recordOptions; + } + + } + + + private TrueFalseUnset checkEnabled() { TrueFalseUnset effective = getEnabled(); diff --git a/source/java/org/alfresco/repo/audit/model/ApplicationAuditEntry.java b/source/java/org/alfresco/repo/audit/model/ApplicationAuditEntry.java index 6cb94e43a8..bb7d6dd7f7 100644 --- a/source/java/org/alfresco/repo/audit/model/ApplicationAuditEntry.java +++ b/source/java/org/alfresco/repo/audit/model/ApplicationAuditEntry.java @@ -61,7 +61,7 @@ public class ApplicationAuditEntry extends AbstractNamedAuditEntry implements Ap public RecordOptions getAuditRecordOptions(String application) { - throw new UnsupportedOperationException(); + return getEffectiveRecordOptions(); } diff --git a/source/java/org/alfresco/repo/audit/model/AuditEntry.java b/source/java/org/alfresco/repo/audit/model/AuditEntry.java index d364d0000f..0534ae590d 100644 --- a/source/java/org/alfresco/repo/audit/model/AuditEntry.java +++ b/source/java/org/alfresco/repo/audit/model/AuditEntry.java @@ -48,7 +48,7 @@ import org.springframework.beans.factory.InitializingBean; public class AuditEntry extends AbstractAuditEntry implements InitializingBean, AuditModel { private static Log s_logger = LogFactory.getLog(AuditEntry.class); - + private Map services = new HashMap(); private Map applications = new HashMap(); @@ -85,8 +85,6 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, configure(null, root, namespacePrefixResolver); } - - @Override void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver) { @@ -98,7 +96,7 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, { throw new AuditModelException("Audit model has incorrect root node"); } - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { s_logger.debug("Audit configuration"); } @@ -106,7 +104,7 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, // Add services - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { s_logger.debug("Adding services ..."); } @@ -120,7 +118,7 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, // Add Applications - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { s_logger.debug("Adding applications ..."); } @@ -137,21 +135,29 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, { String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi); ServiceAuditEntry service = services.get(serviceName); - if(service != null) + if (service != null) { - return service.beforeExecution(auditMode, mi); + MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName()); + if (method != null) + { + return method.beforeExecution(auditMode, mi); + } + else + { + return service.beforeExecution(auditMode, mi); + } } else { - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("No specific audit entry for service "+serviceName); + s_logger.debug("No specific audit entry for service " + serviceName); } return getEffectiveAuditMode(); - + } } - + public AuditMode afterExecution(AuditMode auditMode, MethodInvocation mi) { throw new UnsupportedOperationException(); @@ -159,7 +165,29 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, public RecordOptions getAuditRecordOptions(MethodInvocation mi) { - throw new UnsupportedOperationException(); + String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi); + ServiceAuditEntry service = services.get(serviceName); + if (service != null) + { + MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName()); + if (method != null) + { + return method.getAuditRecordOptions(mi); + } + else + { + return service.getAuditRecordOptions(mi); + } + } + else + { + if (s_logger.isDebugEnabled()) + { + s_logger.debug("No specific audit entry for service " + serviceName); + } + return getEffectiveRecordOptions(); + + } } public AuditMode onError(AuditMode auditMode, MethodInvocation mi) @@ -195,18 +223,18 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, public AuditMode beforeExecution(AuditMode auditMode, String application, String description, NodeRef key, Object... args) { ApplicationAuditEntry aae = applications.get(application); - if(aae != null) + if (aae != null) { return aae.beforeExecution(auditMode, application, description, key, args); } else { - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("No specific audit entry for application "+application); + s_logger.debug("No specific audit entry for application " + application); } return getEffectiveAuditMode(); - + } } @@ -222,25 +250,46 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean, public RecordOptions getAuditRecordOptions(String application) { - throw new UnsupportedOperationException(); - } - - public TrueFalseUnset getAuditInternalServiceMethods( MethodInvocation mi) - { - String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi); - ServiceAuditEntry service = services.get(serviceName); - if(service != null) + ApplicationAuditEntry aae = applications.get(application); + if (aae != null) { - return service.getAuditInternalServiceMethods( mi); + return aae.getAuditRecordOptions(application); } else { - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("No specific audit entry for service "+serviceName); + s_logger.debug("No specific audit entry for application " + application); + } + return getEffectiveRecordOptions(); + + } + } + + public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi) + { + String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi); + ServiceAuditEntry service = services.get(serviceName); + if (service != null) + { + MethodAuditEntry method = service.getMethodAuditEntry(mi.getMethod().getName()); + if (method != null) + { + return method.getAuditInternalServiceMethods(mi); + } + else + { + return service.getAuditInternalServiceMethods(mi); + } + } + else + { + if (s_logger.isDebugEnabled()) + { + s_logger.debug("No specific audit entry for service " + serviceName); } return getEffectiveAuditInternal(); - + } } diff --git a/source/java/org/alfresco/repo/audit/model/MethodAuditEntry.java b/source/java/org/alfresco/repo/audit/model/MethodAuditEntry.java index 8866376496..15f07a3d87 100644 --- a/source/java/org/alfresco/repo/audit/model/MethodAuditEntry.java +++ b/source/java/org/alfresco/repo/audit/model/MethodAuditEntry.java @@ -26,6 +26,7 @@ package org.alfresco.repo.audit.model; import org.alfresco.repo.audit.AuditMode; import org.alfresco.repo.audit.MethodAuditModel; +import org.alfresco.repo.audit.RecordOptions; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -59,9 +60,9 @@ public class MethodAuditEntry extends AbstractNamedAuditEntry implements MethodA throw new UnsupportedOperationException(); } - public RecordOptionsImpl getAuditRecordOptions(MethodInvocation mi) + public RecordOptions getAuditRecordOptions(MethodInvocation mi) { - throw new UnsupportedOperationException(); + return getEffectiveRecordOptions(); } public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi) diff --git a/source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java b/source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java index beb7df8249..449f80c6d3 100644 --- a/source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java +++ b/source/java/org/alfresco/repo/audit/model/ServiceAuditEntry.java @@ -31,6 +31,7 @@ import java.util.Map; import org.alfresco.repo.audit.AuditMode; import org.alfresco.repo.audit.AuditModel; import org.alfresco.repo.audit.MethodAuditModel; +import org.alfresco.repo.audit.RecordOptions; import org.alfresco.service.namespace.NamespacePrefixResolver; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; @@ -40,7 +41,7 @@ import org.dom4j.Element; public class ServiceAuditEntry extends AbstractNamedAuditEntry implements MethodAuditModel { private static Log s_logger = LogFactory.getLog(ServiceAuditEntry.class); - + private Map methods = new HashMap(); public ServiceAuditEntry() @@ -55,9 +56,9 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method // Add Methods - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("Adding methods to service "+getName()); + s_logger.debug("Adding methods to service " + getName()); } for (Iterator nsit = element.elementIterator(AuditModel.EL_METHOD); nsit.hasNext(); /**/) { @@ -66,9 +67,9 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method method.configure(this, methodElement, namespacePrefixResolver); methods.put(method.getName(), method); } - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("...added methods for service "+getName()); + s_logger.debug("...added methods for service " + getName()); } } @@ -82,9 +83,9 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method } else { - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("Evaluating if service is audited (no specific setting) for "+getName()+"."+methodName); + s_logger.debug("Evaluating if service is audited (no specific setting) for " + getName() + "." + methodName); } return getEffectiveAuditMode(); } @@ -100,9 +101,9 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method throw new UnsupportedOperationException(); } - public RecordOptionsImpl getAuditRecordOptions(MethodInvocation mi) + public RecordOptions getAuditRecordOptions(MethodInvocation mi) { - throw new UnsupportedOperationException(); + return getEffectiveRecordOptions(); } public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi) @@ -115,12 +116,17 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method } else { - if(s_logger.isDebugEnabled()) + if (s_logger.isDebugEnabled()) { - s_logger.debug("Evaluating if service is internally audited (no specific setting) for "+getName()+"."+methodName); + s_logger.debug("Evaluating if service is internally audited (no specific setting) for " + getName() + "." + methodName); } return getEffectiveAuditInternal(); } } + + public MethodAuditEntry getMethodAuditEntry(String name) + { + return methods.get(name); + } }