mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged BRANCHES/DEV/V3.4-BUG-FIX to HEAD
Fix build failures related to Audit 28511: Fix build - VersionMigratorTest testMigrateVersionWithAssocs - defaultOnCreateVersion() being called for each aspect as default policy was bound as a service. 28505: Test failure - AbstractVersionServiceImpl was not running defaultOnCreateVersion() as AccessAuditor provided a policy to listen to events. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28517 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -141,7 +141,7 @@ public class AccessAuditorTest
|
|||||||
|
|
||||||
// Mock up an auditComponent to see the results of our tests
|
// Mock up an auditComponent to see the results of our tests
|
||||||
AuditComponent auditComponent = mock(AuditComponent.class);
|
AuditComponent auditComponent = mock(AuditComponent.class);
|
||||||
when(auditComponent.areAuditValuesRequired()).thenReturn(true);
|
when(auditComponent.areAuditValuesRequired(anyString())).thenReturn(true);
|
||||||
when(auditComponent.recordAuditValues(anyString(), anyMap())).thenAnswer(new Answer<Map<String, Serializable>>()
|
when(auditComponent.recordAuditValues(anyString(), anyMap())).thenAnswer(new Answer<Map<String, Serializable>>()
|
||||||
{
|
{
|
||||||
public Map<String, Serializable> answer(InvocationOnMock invocation) throws Throwable
|
public Map<String, Serializable> answer(InvocationOnMock invocation) throws Throwable
|
||||||
|
@@ -48,6 +48,8 @@ import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|||||||
import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy;
|
import org.alfresco.repo.version.VersionServicePolicies.OnCreateVersionPolicy;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.namespace.InvalidQNameException;
|
||||||
|
import org.alfresco.service.namespace.NamespaceException;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
@@ -573,7 +575,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
// Audit QNames with the prefix set. The key can be used in original Set and
|
// Audit QNames with the prefix set. The key can be used in original Set and
|
||||||
// Map operations as only the namesapace and local name are used in equals and
|
// Map operations as only the namesapace and local name are used in equals and
|
||||||
// hashcode methods.
|
// hashcode methods.
|
||||||
QName key = entry.getKey().getPrefixedQName(namespaceService);
|
QName key = getPrefixedQName(entry.getKey());
|
||||||
|
|
||||||
String name = replaceInvalidPathChars(key.toPrefixString());
|
String name = replaceInvalidPathChars(key.toPrefixString());
|
||||||
Serializable beforeValue = entry.getValue();
|
Serializable beforeValue = entry.getValue();
|
||||||
@@ -612,7 +614,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
newKeys.removeAll(fromProperties.keySet());
|
newKeys.removeAll(fromProperties.keySet());
|
||||||
for (QName key: newKeys)
|
for (QName key: newKeys)
|
||||||
{
|
{
|
||||||
key = key.getPrefixedQName(namespaceService); // Audit QNames with the prefix set.
|
// Audit QNames with the prefix set.
|
||||||
|
key = getPrefixedQName(key);
|
||||||
|
|
||||||
Serializable afterValue = toProperties.get(key);
|
Serializable afterValue = toProperties.get(key);
|
||||||
String name = replaceInvalidPathChars(key.toPrefixString());
|
String name = replaceInvalidPathChars(key.toPrefixString());
|
||||||
auditMap.put(buildPath(PROPERTIES, ADD, name), afterValue);
|
auditMap.put(buildPath(PROPERTIES, ADD, name), afterValue);
|
||||||
@@ -648,7 +652,9 @@ import org.alfresco.service.namespace.QName;
|
|||||||
HashSet<QName> prefixedAspects = new HashSet<QName>(aspects.size());
|
HashSet<QName> prefixedAspects = new HashSet<QName>(aspects.size());
|
||||||
for (QName aspect: aspects)
|
for (QName aspect: aspects)
|
||||||
{
|
{
|
||||||
aspect = aspect.getPrefixedQName(namespaceService); // Audit QNames with the prefix set.
|
// Audit QNames with the prefix set.
|
||||||
|
aspect = getPrefixedQName(aspect);
|
||||||
|
|
||||||
prefixedAspects.add(aspect);
|
prefixedAspects.add(aspect);
|
||||||
String name = replaceInvalidPathChars(aspect.toPrefixString());
|
String name = replaceInvalidPathChars(aspect.toPrefixString());
|
||||||
auditMap.put(buildPath(ASPECTS, addOrDelete, name), null);
|
auditMap.put(buildPath(ASPECTS, addOrDelete, name), null);
|
||||||
@@ -664,7 +670,25 @@ import org.alfresco.service.namespace.QName;
|
|||||||
{
|
{
|
||||||
for (Map.Entry<String, Serializable> entry: properties.entrySet())
|
for (Map.Entry<String, Serializable> entry: properties.entrySet())
|
||||||
{
|
{
|
||||||
auditMap.put(buildPath(VERSION_PROPERTIES, entry.getKey()), entry.getValue());
|
// The key may be the string version ({URI}localName) of a QName.
|
||||||
|
// If so get the prefixed version.
|
||||||
|
String key = entry.getKey();
|
||||||
|
if (key.indexOf(QName.NAMESPACE_PREFIX) == 0)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QName qNameKey = QName.createQName(key);
|
||||||
|
qNameKey = getPrefixedQName(qNameKey);
|
||||||
|
key = qNameKey.toPrefixString();
|
||||||
|
}
|
||||||
|
catch (InvalidQNameException e)
|
||||||
|
{
|
||||||
|
// Its just a String.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = replaceInvalidPathChars(key);
|
||||||
|
auditMap.put(buildPath(VERSION_PROPERTIES, name), entry.getValue());
|
||||||
}
|
}
|
||||||
if (!subAction)
|
if (!subAction)
|
||||||
{
|
{
|
||||||
@@ -725,6 +749,22 @@ import org.alfresco.service.namespace.QName;
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a new QName that has the prefix set or the original if it is unknown.
|
||||||
|
*/
|
||||||
|
private QName getPrefixedQName(QName qName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
qName = qName.getPrefixedQName(namespaceService);
|
||||||
|
}
|
||||||
|
catch (NamespaceException e)
|
||||||
|
{
|
||||||
|
// ignore - go with what we have
|
||||||
|
}
|
||||||
|
return qName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a String where all invalid audit path characters are replaced by a '-'.
|
* @return a String where all invalid audit path characters are replaced by a '-'.
|
||||||
*/
|
*/
|
||||||
|
@@ -178,9 +178,6 @@ public abstract class AbstractVersionServiceImpl
|
|||||||
NodeRef nodeRef,
|
NodeRef nodeRef,
|
||||||
Map<String, Serializable> versionProperties,
|
Map<String, Serializable> versionProperties,
|
||||||
PolicyScope nodeDetails)
|
PolicyScope nodeDetails)
|
||||||
{
|
|
||||||
Collection<OnCreateVersionPolicy> policies = this.onCreateVersionDelegate.getList(classRef);
|
|
||||||
if (policies.size() == 0)
|
|
||||||
{
|
{
|
||||||
// Call the default implementation
|
// Call the default implementation
|
||||||
defaultOnCreateVersion(
|
defaultOnCreateVersion(
|
||||||
@@ -188,10 +185,9 @@ public abstract class AbstractVersionServiceImpl
|
|||||||
nodeRef,
|
nodeRef,
|
||||||
versionProperties,
|
versionProperties,
|
||||||
nodeDetails);
|
nodeDetails);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Call the policy definitions
|
// Call the policy definitions
|
||||||
|
Collection<OnCreateVersionPolicy> policies = this.onCreateVersionDelegate.getList(classRef);
|
||||||
for (VersionServicePolicies.OnCreateVersionPolicy policy : policies)
|
for (VersionServicePolicies.OnCreateVersionPolicy policy : policies)
|
||||||
{
|
{
|
||||||
policy.onCreateVersion(
|
policy.onCreateVersion(
|
||||||
@@ -201,11 +197,10 @@ public abstract class AbstractVersionServiceImpl
|
|||||||
nodeDetails);
|
nodeDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of the on create version policy. Called if no behaviour is registered for the
|
* Default implementation of the on create version policy.
|
||||||
* policy for the specified type.
|
* Override if you wish to supply your own policy.
|
||||||
*
|
*
|
||||||
* @param nodeRef
|
* @param nodeRef
|
||||||
* @param versionProperties
|
* @param versionProperties
|
||||||
|
Reference in New Issue
Block a user