diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties index 76742abc10..2f6cafb272 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -56,4 +56,6 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info # Job debug # #log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug -log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info \ No newline at end of file +log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info + +log4j.logger.org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAOImpl=debug \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java index 235fc891cf..69d9f47b29 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/query/RecordsManagementQueryDAOImpl.java @@ -43,7 +43,6 @@ import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.version.Version2Model; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; -import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.namespace.QName; import org.alfresco.util.Pair; import org.apache.commons.logging.Log; @@ -58,6 +57,11 @@ import org.mybatis.spring.SqlSessionTemplate; */ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel { + /** logger */ + @SuppressWarnings("unused") + private static final Log logger = LogFactory.getLog(RecordsManagementQueryDAOImpl.class); + + /** query names */ private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier"; private static final String GET_CHILDREN_PROPERTY_VALUES = "select_GetStringPropertyValuesOfChildren"; private static final String SELECT_NODE_IDS_WHICH_REFERENCE_CONTENT_URL = "select_NodeIdsWhichReferenceContentUrl"; @@ -152,9 +156,21 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, } + /** + * Get a set of node reference which reference the provided content URL + * + * @param String contentUrl content URL + * @return Set set of node references as strings + */ @Override public Set getNodeRefsWhichReferenceContentUrl(String contentUrl) { + if (logger.isDebugEnabled()) + { + logger.debug("Getting nodes that reference content URL = " + contentUrl); + } + + // create the content URL entity used to query for nodes ContentUrlEntity contentUrlEntity = new ContentUrlEntity(); contentUrlEntity.setContentUrl(contentUrl); if (contentUrlEntity.getContentUrlShort() != null) @@ -162,28 +178,60 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, contentUrlEntity.setContentUrlShort(contentUrlEntity.getContentUrlShort().toLowerCase()); } + if (logger.isDebugEnabled()) + { + logger.debug("Executing query " + SELECT_NODE_IDS_WHICH_REFERENCE_CONTENT_URL); + } + // Get all the node ids which reference the given content url List nodeIds = template.selectList(SELECT_NODE_IDS_WHICH_REFERENCE_CONTENT_URL, contentUrlEntity); + + if (logger.isDebugEnabled()) + { + logger.debug("Query " + SELECT_NODE_IDS_WHICH_REFERENCE_CONTENT_URL + " returned " + nodeIds.size() + " results"); + } // create a set of uuids which reference the content url Set nodesReferencingContentUrl = new HashSet<>(); for(Long nodeId : nodeIds) { + StringBuilder logMessage = null; String uuidToAdd; + + 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) - { + { uuidToAdd = version2FrozenNodeRef.getId(); + + if (logger.isDebugEnabled()) + { + logMessage.append(uuidToAdd).append(" (from version)"); + } } // add the uuid for the node ref of the referencing node else { uuidToAdd = (String) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_NODE_UUID); + + if (logger.isDebugEnabled()) + { + logMessage.append(uuidToAdd); + } } + nodesReferencingContentUrl.add(uuidToAdd); + + if (logger.isDebugEnabled()) + { + logger.debug(logMessage.toString()); + } } return nodesReferencingContentUrl; diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java index e6ed70983b..5de7ee766c 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/issue/RM4804Test.java @@ -46,8 +46,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.springframework.extensions.webscripts.GUID; -import javax.xml.soap.Node; - /** * Integration test for RM-4804 *