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
This commit is contained in:
Derek Hulley
2008-10-06 10:25:07 +00:00
parent 8020b0b80c
commit 62c7b53c79
14 changed files with 318 additions and 51 deletions

View File

@@ -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();

View File

@@ -61,7 +61,7 @@ public class ApplicationAuditEntry extends AbstractNamedAuditEntry implements Ap
public RecordOptions getAuditRecordOptions(String application)
{
throw new UnsupportedOperationException();
return getEffectiveRecordOptions();
}

View File

@@ -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<String, ServiceAuditEntry> services = new HashMap<String, ServiceAuditEntry>();
private Map<String, ApplicationAuditEntry> applications = new HashMap<String, ApplicationAuditEntry>();
@@ -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();
}
}

View File

@@ -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)

View File

@@ -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<String, MethodAuditEntry> methods = new HashMap<String, MethodAuditEntry>();
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);
}
}