mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix CapabilitiesTest
- AuditComponentImpl should run data extractors as system user - Simplified CMISChangeLogDataExtractor to use CMISServices git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18878 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,9 +28,10 @@ import java.io.Serializable;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.alfresco.cmis.CMISDictionaryModel;
|
import org.alfresco.cmis.CMISDictionaryModel;
|
||||||
|
import org.alfresco.cmis.CMISInvalidArgumentException;
|
||||||
import org.alfresco.cmis.CMISServices;
|
import org.alfresco.cmis.CMISServices;
|
||||||
|
import org.alfresco.cmis.CMISTypeId;
|
||||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
|
||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
@@ -43,7 +44,6 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
||||||
{
|
{
|
||||||
private CMISServices cmisService;
|
private CMISServices cmisService;
|
||||||
private FileFolderService fileFolderService;
|
|
||||||
|
|
||||||
public static final String KEY_NODE_REF = "nodeRef";
|
public static final String KEY_NODE_REF = "nodeRef";
|
||||||
public static final String KEY_OBJECT_ID = "objectId";
|
public static final String KEY_OBJECT_ID = "objectId";
|
||||||
@@ -69,28 +69,23 @@ public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
|||||||
*/
|
*/
|
||||||
public boolean isSupported(Serializable data)
|
public boolean isSupported(Serializable data)
|
||||||
{
|
{
|
||||||
boolean result = false;
|
|
||||||
if (data != null)
|
if (data != null)
|
||||||
{
|
{
|
||||||
NodeRef nodeRef = getNodeRef(data);
|
NodeRef nodeRef = getNodeRef(data);
|
||||||
if (nodeRef != null)
|
if (nodeRef != null)
|
||||||
{
|
{
|
||||||
if (!fileFolderService.exists(nodeRef))
|
try
|
||||||
{
|
{
|
||||||
result = true;
|
CMISTypeId typeId = cmisService.getTypeDefinition(nodeRef).getBaseType().getTypeId();
|
||||||
|
return typeId.equals(CMISDictionaryModel.DOCUMENT_TYPE_ID) || typeId.equals(CMISDictionaryModel.FOLDER_TYPE_ID);
|
||||||
}
|
}
|
||||||
// Does the node represent a file or folder
|
catch (CMISInvalidArgumentException e)
|
||||||
else if (fileFolderService.getFileInfo(nodeRef) != null)
|
|
||||||
{
|
{
|
||||||
// Is the node located within CMIS defaultRootStore
|
// Ignore and return false
|
||||||
if (cmisService.getDefaultRootStoreRef().equals(nodeRef.getStoreRef()))
|
|
||||||
{
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -122,15 +117,4 @@ public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
|||||||
{
|
{
|
||||||
this.cmisService = cmisService;
|
this.cmisService = cmisService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the FileFolder service
|
|
||||||
*
|
|
||||||
* @param fileFolderService FileFolder service
|
|
||||||
*/
|
|
||||||
public void setFileFolderService(FileFolderService fileFolderService)
|
|
||||||
{
|
|
||||||
this.fileFolderService = fileFolderService;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -47,6 +47,7 @@ import org.alfresco.repo.audit.model.TrueFalseUnset;
|
|||||||
import org.alfresco.repo.domain.audit.AuditDAO;
|
import org.alfresco.repo.domain.audit.AuditDAO;
|
||||||
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
import org.alfresco.repo.domain.propval.PropertyValueDAO;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
@@ -1284,9 +1285,9 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
* @return Returns all values as audited
|
* @return Returns all values as audited
|
||||||
*/
|
*/
|
||||||
private Map<String, Serializable> audit(
|
private Map<String, Serializable> audit(
|
||||||
AuditApplication application,
|
final AuditApplication application,
|
||||||
Set<String> disabledPaths,
|
Set<String> disabledPaths,
|
||||||
Map<String, Serializable> values)
|
final Map<String, Serializable> values)
|
||||||
{
|
{
|
||||||
// Get the model ID for the application
|
// Get the model ID for the application
|
||||||
Long applicationId = application.getApplicationId();
|
Long applicationId = application.getApplicationId();
|
||||||
@@ -1327,7 +1328,13 @@ public class AuditComponentImpl implements AuditComponent
|
|||||||
Map<String, Serializable> auditData = generateData(generators);
|
Map<String, Serializable> auditData = generateData(generators);
|
||||||
|
|
||||||
// Now extract values
|
// Now extract values
|
||||||
Map<String, Serializable> extractedData = extractData(application, values);
|
Map<String, Serializable> extractedData = AuthenticationUtil.runAs(new RunAsWork<Map<String, Serializable>>()
|
||||||
|
{
|
||||||
|
public Map<String, Serializable> doWork() throws Exception
|
||||||
|
{
|
||||||
|
return extractData(application, values);
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
|
||||||
// Combine extracted and generated values (extracted data takes precedence)
|
// Combine extracted and generated values (extracted data takes precedence)
|
||||||
auditData.putAll(extractedData);
|
auditData.putAll(extractedData);
|
||||||
|
Reference in New Issue
Block a user