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

@@ -24,6 +24,12 @@
<property name="transactionService">
<ref bean="transactionService"/>
</property>
<property name="nodeService">
<ref bean="nodeService"/>
</property>
<property name="namespacePrefixResolver">
<ref bean="namespaceService"/>
</property>
<property name="auditConfiguration">
<ref bean="auditConfiguration"/>
</property>

View File

@@ -49,6 +49,7 @@
<list>
<value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-MappedFKIndexes.sql</value>
<value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/AlfrescoPostCreate-2.2-Extra.sql</value>
<value>classpath:alfresco/dbscripts/create/2.2/${db.script.dialect}/post-create-indexes-04.sql</value>
<value>classpath:alfresco/dbscripts/create/3.0/${db.script.dialect}/create-activities-extras.sql</value>
</list>
</property>
@@ -78,6 +79,7 @@
<ref bean="patch.db-V2.1-VersionColumns2" />
<ref bean="patch.db-V2.1-JBPMProcessKey" />
<ref bean="patch.db-V2.1-RemoveWcmSubmittedAspect" />
<ref bean="patch.db-V2.1-AuditPathIndex" />
<ref bean="patch.db-V3.0-0-CreateActivitiesExtras" />
</list>
</property>

View File

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

View File

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

View File

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

View File

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

View File

@@ -1411,6 +1411,17 @@
</property>
</bean>
<bean id="patch.db-V2.1-AuditPathIndex" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V2.1-AuditPathIndex</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>132</value></property>
<property name="targetSchema"><value>133</value></property>
<property name="scriptUrl">
<value>classpath:alfresco/dbscripts/upgrade/2.2/${db.script.dialect}/AlfrescoSchemaUpdate-2.1-AuditPathIndex.sql</value>
</property>
</bean>
<bean id="patch.db-V3.0-0-CreateActivitiesExtras" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V3.0-0-CreateActivitiesExtras</value></property>
<property name="description"><value>patch.schemaUpgradeScript.description</value></property>

View File

@@ -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
<<<<<<< .working
version.schema=133

View File

@@ -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
*/
@@ -83,6 +87,10 @@ public class AuditComponentImpl implements AuditComponent
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
*/
@@ -132,6 +142,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;
}
}

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

@@ -85,8 +85,6 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean,
configure(null, root, namespacePrefixResolver);
}
@Override
void configure(AbstractAuditEntry parent, Element element, NamespacePrefixResolver namespacePrefixResolver)
{
@@ -138,9 +136,17 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean,
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.beforeExecution(auditMode, mi);
}
else
{
return service.beforeExecution(auditMode, mi);
}
}
else
{
if (s_logger.isDebugEnabled())
@@ -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)
@@ -222,7 +250,20 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean,
public RecordOptions getAuditRecordOptions(String application)
{
throw new UnsupportedOperationException();
ApplicationAuditEntry aae = applications.get(application);
if (aae != null)
{
return aae.getAuditRecordOptions(application);
}
else
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("No specific audit entry for application " + application);
}
return getEffectiveRecordOptions();
}
}
public TrueFalseUnset getAuditInternalServiceMethods(MethodInvocation mi)
@@ -230,9 +271,17 @@ public class AuditEntry extends AbstractAuditEntry implements InitializingBean,
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())

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;
@@ -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)
@@ -123,4 +124,9 @@ public class ServiceAuditEntry extends AbstractNamedAuditEntry implements Method
}
}
public MethodAuditEntry getMethodAuditEntry(String name)
{
return methods.get(name);
}
}