Heinous merge from HEAD. Seems to basically work. Be on guard however.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4137 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-10-18 02:24:36 +00:00
parent 6441f470f5
commit 111296d4dc
156 changed files with 18940 additions and 14167 deletions

View File

@@ -23,6 +23,7 @@ import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;
import org.alfresco.repo.audit.model.TrueFalseUnset;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.service.Auditable;
@@ -123,13 +124,26 @@ public class AuditComponentImpl implements AuditComponent
{
if ((auditFlag.get() == null) || (!auditFlag.get().booleanValue()))
{
boolean auditInternal = (auditModel.getAuditInternalServiceMethods(mi) == TrueFalseUnset.TRUE);
try
{
auditFlag.set(Boolean.TRUE);
Method method = mi.getMethod();
String methodName = method.getName();
String serviceName = publicServiceIdentifier.getPublicServiceName(mi);
if (!auditInternal)
{
auditFlag.set(Boolean.TRUE);
}
else
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("Auditing internal service use for - " + serviceName + "." + methodName);
}
}
if (method.isAnnotationPresent(Auditable.class))
{
@@ -170,7 +184,10 @@ public class AuditComponentImpl implements AuditComponent
}
finally
{
auditFlag.set(Boolean.FALSE);
if (!auditInternal)
{
auditFlag.set(Boolean.FALSE);
}
}
}
else
@@ -272,7 +289,7 @@ public class AuditComponentImpl implements AuditComponent
}
else if (returnObject instanceof StoreRef)
{
auditInfo.setKeyStore((StoreRef)returnObject);
auditInfo.setKeyStore((StoreRef) returnObject);
}
}
}

View File

@@ -35,6 +35,7 @@ import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.PropertyMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -126,7 +127,7 @@ public class AuditableAspect
public void onAddAudit(NodeRef nodeRef, QName aspect)
{
// Get the current properties
Map<QName, Serializable> properties = this.nodeService.getProperties(nodeRef);
PropertyMap properties = new PropertyMap();
// Set created / updated date
Date now = new Date(System.currentTimeMillis());
@@ -167,7 +168,7 @@ public class AuditableAspect
// Get the current properties
try
{
Map<QName, Serializable> properties = this.nodeService.getProperties(nodeRef);
PropertyMap properties = new PropertyMap();
// Set updated date
Date now = new Date(System.currentTimeMillis());
@@ -249,7 +250,11 @@ public class AuditableAspect
*/
public Boolean doWork() throws Exception
{
nodeService.setProperties(nodeRef, properties);
for (QName propertyQName : properties.keySet())
{
Serializable property = properties.get(propertyQName);
nodeService.setProperty(nodeRef, propertyQName, property);
}
return Boolean.TRUE;
}
}

View File

@@ -16,6 +16,7 @@
*/
package org.alfresco.repo.audit;
import org.alfresco.repo.audit.model.TrueFalseUnset;
import org.aopalliance.intercept.MethodInvocation;
public interface MethodAuditModel
@@ -54,4 +55,11 @@ public interface MethodAuditModel
* @return
*/
public RecordOptions getAuditRecordOptions(MethodInvocation mi);
/**
* Should internal service class be logged.
*
* @return
*/
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi);
}

View File

@@ -42,10 +42,10 @@
<property name="fail" column="fail" type="boolean" not-null="true"/>
<!-- TODO: Check the URL length ...-->
<property name="serialisedURL" column="serialized_url" type="string" length="1024" not-null="false"/>
<property name="exception" column="exception" type="string" length="1024" not-null="false"/>
<property name="exception" column="exception_message" type="string" length="1024" not-null="false"/>
<property name="hostInetAddress" column="host_address" type="string" length="1024" not-null="false"/>
<property name="clientInetAddress" column="client_address" type="string" length="1024" not-null="false"/>
<property name="message" column="message" type="string" length="1024" not-null="false"/>
<property name="message" column="message_text" type="string" length="1024" not-null="false"/>
<!-- Links to dimensions -->
@@ -67,7 +67,7 @@
<!-- Date is used as the key for look up -->
<property name="date" column="date" type="date" index="adt_date_idx" not-null="true"/>
<property name="date" column="date_only" type="date" index="adt_date_idx" not-null="true"/>
<property name="dayOfYear" column="day_of_year" type="integer" index="adt_doy_idx" not-null="true"/>
<property name="dayOfMonth" column="day_of_month" type="integer" index="adt_dom_idx" not-null="true"/>
<property name="dayOfWeek" column="day_of_week" type="integer" index="adt_dow_idx" not-null="true"/>
@@ -135,24 +135,34 @@
<query name="audit.GetAuditSourceByApplication">
select
audit_store
audit_store_byid
from
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store_byid
where
audit_store_byid =
(select max(audit_store.id)
from
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
where
audit_store.application = :application and
audit_store.service is null and
audit_store.method is null
audit_store.method is null)
</query>
<query name="audit.GetAuditSourceByApplicationServiceMethod">
select
audit_store
audit_store_byid
from
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store_byid
where
audit_store_byid =
(select max(audit_store.id)
from
org.alfresco.repo.audit.hibernate.AuditSourceImpl as audit_store
where
audit_store.application = :application and
audit_store.service = :service and
audit_store.method = :method
audit_store.method = :method)
</query>
<query name="audit.GetAuditTrailForNode">

View File

@@ -136,6 +136,49 @@ public abstract class AbstractAuditEntry
{
return recordOptions;
}
protected TrueFalseUnset getEffectiveAuditInternal()
{
TrueFalseUnset auditInternal;
if (checkEnabled() == TrueFalseUnset.TRUE)
{
auditInternal = getAuditInternalOrParentAuditInternal();
}
else
{
auditInternal = TrueFalseUnset.FALSE;
}
if(s_logger.isDebugEnabled())
{
s_logger.debug("... Effective audit internal is = "+auditInternal);
}
return auditInternal;
}
private TrueFalseUnset getAuditInternalOrParentAuditInternal()
{
TrueFalseUnset auditInternal = getAuditInternal();
if(s_logger.isDebugEnabled())
{
s_logger.debug("... ... audit internal is = "+auditInternal);
}
if (auditInternal == TrueFalseUnset.UNSET)
{
if (getParent() == null)
{
return TrueFalseUnset.UNSET;
}
else
{
return getParent().getAuditInternalOrParentAuditInternal();
}
}
else
{
return auditInternal;
}
}
protected AuditMode getEffectiveAuditMode()
{

View File

@@ -217,4 +217,23 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean,
throw new UnsupportedOperationException();
}
public TrueFalseUnset getAuditInternalServiceMethods( MethodInvocation mi)
{
String serviceName = getPublicServiceIdentifier().getPublicServiceName(mi);
ServiceAuditEntry service = services.get(serviceName);
if(service != null)
{
return service.getAuditInternalServiceMethods( mi);
}
else
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("No specific audit entry for service "+serviceName);
}
return getEffectiveAuditInternal();
}
}
}

View File

@@ -56,4 +56,13 @@ public class MethodAuditEntry extends AbstractNamedAuditEntry implements MethodA
throw new UnsupportedOperationException();
}
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("Evaluating if method is internally audited ..."+((ServiceAuditEntry)getParent()).getName()+"."+getName());
}
return getEffectiveAuditInternal();
}
}

View File

@@ -97,4 +97,22 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method
throw new UnsupportedOperationException();
}
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
{
String methodName = mi.getMethod().getName();
MethodAuditEntry method = methods.get(methodName);
if (method != null)
{
return method.getAuditInternalServiceMethods(mi);
}
else
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("Evaluating if service is internally audited (no specific setting) for "+getName()+"."+methodName);
}
return getEffectiveAuditInternal();
}
}
}