Tweaks for ALF-4529: Database connection problems when upgrading large sample 2.1.x data set

- Handle invalid child association QNames
 - Optimization on an array copy


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@23238 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-10-22 20:21:10 +00:00
parent f2f318b89b
commit f48288b5a5
3 changed files with 16 additions and 0 deletions

View File

@@ -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}.

View File

@@ -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();

View File

@@ -415,6 +415,12 @@ public class PatchDAOImpl extends AbstractPatchDAOImpl
try
{
List<Map<String, Object>> 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