mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Fix issue with inaccurate results returning from content URL query
* added integration test for MNT scenarios * checked for nodeId's that don't exist in query results * changed DAO method to return set of node references rather tha nodeId strings * turned off logging by default
This commit is contained in:
@@ -57,5 +57,4 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
|||||||
#
|
#
|
||||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||||
log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info
|
log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info
|
||||||
|
log4j.logger.org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl=info
|
||||||
log4j.logger.org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl=debug
|
|
@@ -64,7 +64,7 @@ public interface RecordsManagementQueryDAO
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param contentUrl the URL of the content url entity
|
* @param contentUrl the URL of the content url entity
|
||||||
* @return Return a set of UUIDs which reference the given node
|
* @return Set<NodeRef> a set of nodes that reference the given content url
|
||||||
*/
|
*/
|
||||||
Set<String> getNodeRefsWhichReferenceContentUrl(String contentUrl);
|
Set<NodeRef> getNodeRefsWhichReferenceContentUrl(String contentUrl);
|
||||||
}
|
}
|
||||||
|
@@ -34,7 +34,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
|
||||||
import org.alfresco.repo.domain.contentdata.ContentUrlEntity;
|
import org.alfresco.repo.domain.contentdata.ContentUrlEntity;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
@@ -159,11 +158,11 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
|||||||
/**
|
/**
|
||||||
* Get a set of node reference which reference the provided content URL
|
* Get a set of node reference which reference the provided content URL
|
||||||
*
|
*
|
||||||
* @param String contentUrl content URL
|
* @param String contentUrl content URL
|
||||||
* @return Set<String> set of node references as strings
|
* @return Set<NodeRef> set of nodes that reference the provided content URL
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getNodeRefsWhichReferenceContentUrl(String contentUrl)
|
public Set<NodeRef> getNodeRefsWhichReferenceContentUrl(String contentUrl)
|
||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
@@ -192,45 +191,54 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create a set of uuids which reference the content url
|
// create a set of uuids which reference the content url
|
||||||
Set<String> nodesReferencingContentUrl = new HashSet<>();
|
Set<NodeRef> nodesReferencingContentUrl = new HashSet<NodeRef>(nodeIds.size());
|
||||||
for(Long nodeId : nodeIds)
|
for(Long nodeId : nodeIds)
|
||||||
{
|
{
|
||||||
StringBuilder logMessage = null;
|
StringBuilder logMessage = null;
|
||||||
String uuidToAdd;
|
NodeRef nodeRefToAdd;
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
if (nodeDAO.exists(nodeId))
|
||||||
{
|
{
|
||||||
logMessage = new StringBuilder("Adding uuid ");
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logMessage = new StringBuilder("Adding uuid ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the referencing node is a version2Store reference to the content url, add the uuid for the version 2 frozen node ref
|
||||||
|
NodeRef version2FrozenNodeRef = (NodeRef) nodeDAO.getNodeProperty(nodeId, Version2Model.PROP_QNAME_FROZEN_NODE_REF);
|
||||||
|
if (version2FrozenNodeRef != null)
|
||||||
|
{
|
||||||
|
nodeRefToAdd = version2FrozenNodeRef;
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logMessage.append(nodeRefToAdd).append(" (from version)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the uuid for the node ref of the referencing node
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodeRefToAdd = nodeDAO.getNodeIdStatus(nodeId).getNodeRef();
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logMessage.append(nodeRefToAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodesReferencingContentUrl.add(nodeRefToAdd);
|
||||||
|
|
||||||
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug(logMessage.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the referencing node is a version2Store reference to the content url, add the uuid for the version 2 frozen node ref
|
|
||||||
NodeRef version2FrozenNodeRef = (NodeRef) nodeDAO.getNodeProperty(nodeId, Version2Model.PROP_QNAME_FROZEN_NODE_REF);
|
|
||||||
if (version2FrozenNodeRef != null)
|
|
||||||
{
|
|
||||||
uuidToAdd = version2FrozenNodeRef.getId();
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logMessage.append(uuidToAdd).append(" (from version)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// add the uuid for the node ref of the referencing node
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uuidToAdd = (String) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_NODE_UUID);
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
if (logger.isDebugEnabled())
|
logger.debug("Not adding " + nodeId + " (exist==false)");
|
||||||
{
|
}
|
||||||
logMessage.append(uuidToAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nodesReferencingContentUrl.add(uuidToAdd);
|
|
||||||
|
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug(logMessage.toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -96,7 +96,7 @@ public class ContentBinDuplicationUtility extends ServiceBaseImpl
|
|||||||
boolean hasAtLeastOneOtherReference = false;
|
boolean hasAtLeastOneOtherReference = false;
|
||||||
String contentUrl = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT).getContentUrl();
|
String contentUrl = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT).getContentUrl();
|
||||||
|
|
||||||
Set<String> referencesToContentNode = recordsManagementQueryDAO.getNodeRefsWhichReferenceContentUrl(contentUrl);
|
Set<NodeRef> referencesToContentNode = recordsManagementQueryDAO.getNodeRefsWhichReferenceContentUrl(contentUrl);
|
||||||
if (referencesToContentNode.size() > 1)
|
if (referencesToContentNode.size() > 1)
|
||||||
{
|
{
|
||||||
hasAtLeastOneOtherReference = true;
|
hasAtLeastOneOtherReference = true;
|
||||||
|
@@ -54,7 +54,6 @@ import org.alfresco.module.org_alfresco_module_rm.recordfolder.RecordFolderServi
|
|||||||
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
import org.alfresco.module.org_alfresco_module_rm.report.ReportService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
import org.alfresco.module.org_alfresco_module_rm.role.FilePlanRoleService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.role.Role;
|
|
||||||
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
import org.alfresco.module.org_alfresco_module_rm.search.RecordsManagementSearchService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
import org.alfresco.module.org_alfresco_module_rm.security.FilePlanPermissionService;
|
||||||
|
@@ -116,8 +116,8 @@ public class ContentBinDuplicationUtilityUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void testHasAtLeastOneOtherReference()
|
public void testHasAtLeastOneOtherReference()
|
||||||
{
|
{
|
||||||
Set<String> multipleReferences = new HashSet<>();
|
Set<NodeRef> multipleReferences = new HashSet<>();
|
||||||
Collections.addAll(multipleReferences, NODE_REF.getId(), NODE_REF2.getId());
|
Collections.addAll(multipleReferences, NODE_REF, NODE_REF2);
|
||||||
|
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
||||||
@@ -132,7 +132,7 @@ public class ContentBinDuplicationUtilityUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void testHasNoOtherReference()
|
public void testHasNoOtherReference()
|
||||||
{
|
{
|
||||||
Set<String> singleReference = Collections.singleton(NODE_REF.getId());
|
Set<NodeRef> singleReference = Collections.singleton(NODE_REF);
|
||||||
|
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
||||||
@@ -147,7 +147,7 @@ public class ContentBinDuplicationUtilityUnitTest
|
|||||||
@Test
|
@Test
|
||||||
public void testHasNoReferences()
|
public void testHasNoReferences()
|
||||||
{
|
{
|
||||||
Set<String> noReferences = Collections.<String> emptySet();
|
Set<NodeRef> noReferences = Collections.<NodeRef> emptySet();
|
||||||
|
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT)).thenReturn(contentReader);
|
||||||
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
when(contentService.getReader(NODE_REF, ContentModel.PROP_CONTENT).getContentUrl()).thenReturn(CONTENT_URL);
|
||||||
|
Reference in New Issue
Block a user