diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index b2225e56a3..880da3d1d1 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -306,6 +306,7 @@ patch.fixNameCrcValues.description=Fixes name and qname CRC32 values to match UT patch.fixNameCrcValues.result=Fixed CRC32 values for UTF-8 encoding for {0} node child associations. See file {1} for details. patch.fixNameCrcValues.fixed=Updated CRC32 values for association ID {0}, name ''{1}'': {2} -> {3}, qname ''{4}'': {5} -> {6}. patch.fixNameCrcValues.unableToChange=Failed to update the CRC32 value for association ID {0}: \n Node name: {1} \n name CRC old: {2} \n name CRC new: {3} \n qname: {4} \n qname CRC old: {5} \n qname CRC new: {6} \n Error: {7} +patch.fixNameCrcValues.fixingLocalname=Fixing invalid localname for association ID {0}: \n Was: ''{1}'' \n Now: ''{2}'' patch.fixNameCrcValues.associationTypeNotDefined=Association type ''{0}'' has not been defined for child association ID {1}. patch.fixNameCrcValues.associationTypeNotChild=Association type ''{0}'' does not represent a child association but is used as one; for child association ID {1}. diff --git a/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java index 6e9b211f53..ec4b66b751 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/FixNameCrcValuesPatch.java @@ -61,6 +61,7 @@ public class FixNameCrcValuesPatch extends AbstractPatch private static final String MSG_SUCCESS = "patch.fixNameCrcValues.result"; private static final String MSG_REWRITTEN = "patch.fixNameCrcValues.fixed"; private static final String MSG_UNABLE_TO_CHANGE = "patch.fixNameCrcValues.unableToChange"; + private static final String MSG_FIXING_LOCALNAME = "patch.fixNameCrcValues.fixingLocalname"; private static final String ERR_ASSOCIATION_TYPE_NOT_DEFINED = "patch.fixNameCrcValues.associationTypeNotDefined"; private static final String ERR_ASSOCIATION_TYPE_NOT_CHILD = "patch.fixNameCrcValues.associationTypeNotChild"; @@ -282,6 +283,14 @@ public class FixNameCrcValuesPatch extends AbstractPatch String childNodeName = (String) row.get("childNodeName"); // Use the UUID if there is no cm:name childNodeName = (childNodeName == null) ? childNodeUuid : childNodeName; + // Ensure that we generate a valid QName (see comments on ALF-4529) + if (qnameLocalName == null || qnameLocalName.length() == 0) + { + String qnameLocalNameNew = "fix-" + assocId; + logger.warn( + I18NUtil.getMessage(MSG_FIXING_LOCALNAME, assocId, qnameLocalName, qnameLocalNameNew)); + qnameLocalName = qnameLocalNameNew; + } // Resolve QNames QName typeQName = qnameDAO.getQName(typeQNameId).getSecond(); String namespace = qnameDAO.getNamespace(qnameNamespaceId).getSecond(); diff --git a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java index 64e99fd885..b603a85aaa 100644 --- a/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java +++ b/source/java/org/alfresco/repo/domain/patch/ibatis/PatchDAOImpl.java @@ -415,6 +415,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl try { List> rows = template.queryForList(SELECT_CHILD_ASSOCS_FOR_CRCS, entity, 0, queryMaxResults); + if (results.size() == 0 && rows.size() >= maxResults) + { + // We have all we need + results = rows; + break; + } // Add these rows to the result results.addAll(rows); // Calculate new maxResults