mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75520: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (5.0/Cloud) 75206: Merged DEV to V4.2-BUG-FIX (4.2.3) 74383 : MNT-11726 : CMIS change log isn't returning valid cmis:objectId values for deleted objects - Use context safe objectId generation in CMISChangeLogDataExtractor. Test for the fix 74484 : MNT-11726 : CMIS change log isn't returning valid cmis:objectId values for deleted objects - Test implemented in CMISTest - Changed CMISConnector.isFolder(NodeRef) logic. Can cause NPE if NodeRef is not FOLDER or FILE 75113 : MNT-11726 : CMIS change log isn't returning valid cmis:objectId values for deleted objects - alfresco-audit-cmis.xml moved to Repository project git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77482 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -22,7 +22,6 @@ import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
|
||||
import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
|
||||
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
|
||||
import org.alfresco.repo.audit.extractor.AbstractDataExtractor;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
@@ -30,7 +29,6 @@ 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.namespace.QName;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
|
||||
|
||||
/**
|
||||
@@ -46,6 +44,7 @@ public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
||||
|
||||
private NodeService nodeService;
|
||||
private CMISDictionaryService cmisDictionaryService;
|
||||
private CMISConnector cmisConnector;
|
||||
|
||||
/**
|
||||
* Extracts relevant node refs and Ids from auditing data
|
||||
@@ -57,15 +56,10 @@ public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
NodeRef nodeRef = getNodeRef(value);
|
||||
|
||||
QName typeQName = nodeService.getType(nodeRef);
|
||||
TypeDefinitionWrapper type = cmisDictionaryService.findNodeType(typeQName);
|
||||
|
||||
HashMap<String, Serializable> result = new HashMap<String, Serializable>(5);
|
||||
result.put(KEY_NODE_REF, nodeRef);
|
||||
// Support version nodes by recording the object ID
|
||||
CMISPropertyAccessor accessor = type.getPropertyById(PropertyIds.OBJECT_ID).getPropertyAccessor();
|
||||
result.put(KEY_OBJECT_ID, accessor.getValue(accessor.createNodeInfo(nodeRef)));
|
||||
|
||||
result.put(KEY_OBJECT_ID, cmisConnector.createObjectId(nodeRef, true));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -125,4 +119,8 @@ public class CMISChangeLogDataExtractor extends AbstractDataExtractor
|
||||
{
|
||||
this.cmisDictionaryService = cmisDictionaryService;
|
||||
}
|
||||
|
||||
public void setCmisConnector(CMISConnector cmisConnector) {
|
||||
this.cmisConnector = cmisConnector;
|
||||
}
|
||||
}
|
||||
|
@@ -1170,9 +1170,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
* be the assocRef guid.
|
||||
*/
|
||||
public String constructObjectId(AssociationRef assocRef, String versionLabel)
|
||||
{
|
||||
return constructObjectId(assocRef, versionLabel, isPublicApi());
|
||||
}
|
||||
|
||||
public String constructObjectId(AssociationRef assocRef, String versionLabel, boolean dropStoreRef)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(CMISConnector.ASSOC_ID_PREFIX);
|
||||
if(isPublicApi())
|
||||
if(dropStoreRef)
|
||||
{
|
||||
// always return the guid
|
||||
sb.append(assocRef.getId());
|
||||
@@ -1204,9 +1209,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
* be the node guid.
|
||||
*/
|
||||
public String constructObjectId(String incomingNodeId, String versionLabel)
|
||||
{
|
||||
return constructObjectId(incomingNodeId, versionLabel, isPublicApi());
|
||||
}
|
||||
|
||||
public String constructObjectId(String incomingNodeId, String versionLabel, boolean dropStoreRef)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if(isPublicApi())
|
||||
if(dropStoreRef)
|
||||
{
|
||||
// always return the guid
|
||||
sb.append(getGuid(incomingNodeId));
|
||||
@@ -1264,9 +1274,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
* be the incomingNodeRef guid.
|
||||
*/
|
||||
public String constructObjectId(NodeRef incomingNodeRef, String versionLabel)
|
||||
{
|
||||
return constructObjectId(incomingNodeRef, versionLabel, isPublicApi());
|
||||
}
|
||||
|
||||
public String constructObjectId(NodeRef incomingNodeRef, String versionLabel, boolean dropStoreRef)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(isPublicApi() ? incomingNodeRef.getId() : incomingNodeRef.toString());
|
||||
sb.append(dropStoreRef ? incomingNodeRef.getId() : incomingNodeRef.toString());
|
||||
if(versionLabel != null)
|
||||
{
|
||||
sb.append(CMISConnector.ID_SEPERATOR);
|
||||
@@ -1278,29 +1293,39 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
/**
|
||||
* Compiles a CMIS object if for a live node.
|
||||
*/
|
||||
public String createObjectId(NodeRef currentVersionNodeRef)
|
||||
public String createObjectId(NodeRef nodeRef)
|
||||
{
|
||||
QName typeQName = nodeService.getType(currentVersionNodeRef);
|
||||
return createObjectId(nodeRef, isPublicApi());
|
||||
}
|
||||
|
||||
public String createObjectId(NodeRef nodeRef, boolean dropStoreRef)
|
||||
{
|
||||
QName typeQName = nodeService.getType(nodeRef);
|
||||
TypeDefinitionWrapper type = getOpenCMISDictionaryService().findNodeType(typeQName);
|
||||
|
||||
if(type instanceof ItemTypeDefinitionWrapper)
|
||||
{
|
||||
return constructObjectId(currentVersionNodeRef, null);
|
||||
return constructObjectId(nodeRef, null);
|
||||
}
|
||||
|
||||
if(type instanceof FolderTypeDefintionWrapper)
|
||||
{
|
||||
return constructObjectId(currentVersionNodeRef, null);
|
||||
return constructObjectId(nodeRef, null, dropStoreRef);
|
||||
}
|
||||
|
||||
Serializable versionLabel = getNodeService()
|
||||
.getProperty(currentVersionNodeRef, ContentModel.PROP_VERSION_LABEL);
|
||||
.getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
|
||||
if (versionLabel == null)
|
||||
{
|
||||
versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
|
||||
}
|
||||
|
||||
return constructObjectId(currentVersionNodeRef, (String)versionLabel);
|
||||
return constructObjectId(nodeRef, (String)versionLabel, dropStoreRef);
|
||||
}
|
||||
|
||||
private boolean isFolder(NodeRef nodeRef)
|
||||
{
|
||||
return getType(nodeRef) instanceof FolderTypeDefintionWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user