mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Fixed ALF-4190: fixNameCrcValues-2 fails on 3.4
- Finished implementation: Missing bean injection, update parameters wrong way around, etc - Improved performance (negative name crc values can be left as is) - Tested git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -302,8 +302,8 @@
|
|||||||
update
|
update
|
||||||
alf_child_assoc
|
alf_child_assoc
|
||||||
set
|
set
|
||||||
qname_crc = ?,
|
child_node_name_crc = ?,
|
||||||
child_node_name_crc = ?
|
qname_crc = ?
|
||||||
where
|
where
|
||||||
id = ?
|
id = ?
|
||||||
</update>
|
</update>
|
||||||
|
@@ -304,6 +304,8 @@ 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.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.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.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.associationTypeNotDefined=Association type ''{0}'' has not been defined.
|
||||||
|
patch.fixNameCrcValues.associationTypeNotChild=Association type ''{0}'' does not represent a child association but is used as one.
|
||||||
|
|
||||||
patch.personUsagePatch.description=Add person 'cm:sizeCurrent' property (if missing).
|
patch.personUsagePatch.description=Add person 'cm:sizeCurrent' property (if missing).
|
||||||
patch.personUsagePatch.result1=Added 'cm:sizeCurrent' property to {0} people that were missing this property.
|
patch.personUsagePatch.result1=Added 'cm:sizeCurrent' property to {0} people that were missing this property.
|
||||||
|
@@ -1965,6 +1965,9 @@
|
|||||||
<property name="controlDAO">
|
<property name="controlDAO">
|
||||||
<ref bean="controlDAO" />
|
<ref bean="controlDAO" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="dictionaryService">
|
||||||
|
<ref bean="dictionaryService" />
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="patch.redeployNominatedInvitationProcessWithPropsForShare" class="org.alfresco.repo.admin.patch.impl.GenericWorkflowPatch" parent="basePatch" >
|
<bean id="patch.redeployNominatedInvitationProcessWithPropsForShare" class="org.alfresco.repo.admin.patch.impl.GenericWorkflowPatch" parent="basePatch" >
|
||||||
|
@@ -29,6 +29,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.alfresco.error.StackTraceUtil;
|
||||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||||
import org.alfresco.repo.admin.patch.PatchExecuter;
|
import org.alfresco.repo.admin.patch.PatchExecuter;
|
||||||
import org.alfresco.repo.batch.BatchProcessWorkProvider;
|
import org.alfresco.repo.batch.BatchProcessWorkProvider;
|
||||||
@@ -39,6 +40,7 @@ import org.alfresco.repo.domain.node.ChildAssocEntity;
|
|||||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
|
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
import org.alfresco.service.cmr.dictionary.DictionaryException;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -59,6 +61,8 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
private static final String MSG_SUCCESS = "patch.fixNameCrcValues.result";
|
private static final String MSG_SUCCESS = "patch.fixNameCrcValues.result";
|
||||||
private static final String MSG_REWRITTEN = "patch.fixNameCrcValues.fixed";
|
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_UNABLE_TO_CHANGE = "patch.fixNameCrcValues.unableToChange";
|
||||||
|
private static final String ERR_ASSOCIATION_TYPE_NOT_DEFINED = "patch.fixNameCrcValues.associationTypeNotDefined";
|
||||||
|
private static final String ERR_ASSOCIATION_TYPE_NOT_CHILD = "patch.fixNameCrcValues.associationTypeNotChild";
|
||||||
|
|
||||||
private PatchDAO patchDAO;
|
private PatchDAO patchDAO;
|
||||||
private QNameDAO qnameDAO;
|
private QNameDAO qnameDAO;
|
||||||
@@ -107,6 +111,8 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
super.checkProperties();
|
super.checkProperties();
|
||||||
checkPropertyNotNull(patchDAO, "patchDAO");
|
checkPropertyNotNull(patchDAO, "patchDAO");
|
||||||
checkPropertyNotNull(qnameDAO, "qnameDAO");
|
checkPropertyNotNull(qnameDAO, "qnameDAO");
|
||||||
|
checkPropertyNotNull(controlDAO, "controlDAO");
|
||||||
|
checkPropertyNotNull(dictionaryService, "dictionaryService");
|
||||||
checkPropertyNotNull(applicationEventPublisher, "applicationEventPublisher");
|
checkPropertyNotNull(applicationEventPublisher, "applicationEventPublisher");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,11 +242,29 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
ChildAssocEntity entity = new ChildAssocEntity();
|
ChildAssocEntity entity = new ChildAssocEntity();
|
||||||
entity.setChildNodeNameAll(dictionaryService, typeQName, childNodeName);
|
entity.setChildNodeNameAll(dictionaryService, typeQName, childNodeName);
|
||||||
entity.setQNameAll(qnameDAO, qname, false);
|
entity.setQNameAll(qnameDAO, qname, false);
|
||||||
// Check the CRC values for cm:name
|
Long childNodeNameCrcNew = entity.getChildNodeNameCrc();
|
||||||
if (entity.getChildNodeNameCrc().equals(childNodeNameCrc))
|
Long qnameCrcNew = entity.getQnameCrc();
|
||||||
|
entity = null; // Just checking that we don't misuse it
|
||||||
|
|
||||||
|
AssociationDefinition assocDef = dictionaryService.getAssociation(typeQName);
|
||||||
|
if (assocDef == null)
|
||||||
{
|
{
|
||||||
// Check the CRC for the QName
|
throw new DictionaryException(ERR_ASSOCIATION_TYPE_NOT_DEFINED, typeQName, assocId);
|
||||||
if (entity.getQnameCrc().equals(qnameCrc))
|
}
|
||||||
|
else if (!assocDef.isChild())
|
||||||
|
{
|
||||||
|
throw new DictionaryException(ERR_ASSOCIATION_TYPE_NOT_CHILD, typeQName, assocId);
|
||||||
|
}
|
||||||
|
ChildAssociationDefinition childAssocDef = (ChildAssociationDefinition) assocDef;
|
||||||
|
boolean requiresNameConstraint = !childAssocDef.getDuplicateChildNamesAllowed();
|
||||||
|
|
||||||
|
// Check the CRC for the QName
|
||||||
|
if (qnameCrcNew.equals(qnameCrc))
|
||||||
|
{
|
||||||
|
// Check the CRC values for cm:name
|
||||||
|
// - value might have stayed the same
|
||||||
|
// - Any existing name crc negative value is fine if the name constraint need not be enforced
|
||||||
|
if (childNodeNameCrcNew.equals(childNodeNameCrc) || (childNodeNameCrc < 0 && !requiresNameConstraint))
|
||||||
{
|
{
|
||||||
// This child assoc is good
|
// This child assoc is good
|
||||||
return;
|
return;
|
||||||
@@ -250,22 +274,16 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
Savepoint savepoint = null;
|
Savepoint savepoint = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
AssociationDefinition assocDef = dictionaryService.getAssociation(typeQName);
|
|
||||||
if (assocDef == null)
|
|
||||||
{
|
|
||||||
throw new DictionaryException("Association type not defined: " + typeQName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Being here indicates that the association needs to be updated
|
// Being here indicates that the association needs to be updated
|
||||||
savepoint = controlDAO.createSavepoint("FixNameCrcValuesPatch");
|
savepoint = controlDAO.createSavepoint("FixNameCrcValuesPatch");
|
||||||
patchDAO.updateChildAssocCrc(assocId, childNodeNameCrc, qnameCrc);
|
patchDAO.updateChildAssocCrc(assocId, childNodeNameCrcNew, qnameCrcNew);
|
||||||
controlDAO.releaseSavepoint(savepoint);
|
controlDAO.releaseSavepoint(savepoint);
|
||||||
|
|
||||||
String msg = I18NUtil.getMessage(
|
String msg = I18NUtil.getMessage(
|
||||||
MSG_REWRITTEN,
|
MSG_REWRITTEN,
|
||||||
assocId,
|
assocId,
|
||||||
childNodeName, childNodeNameCrc, entity.getChildNodeNameCrc(),
|
childNodeName, childNodeNameCrc, childNodeNameCrcNew,
|
||||||
qname, qnameCrc, entity.getQnameCrc());
|
qname, qnameCrc, qnameCrcNew);
|
||||||
writeLine(msg);
|
writeLine(msg);
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
@@ -277,8 +295,8 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
String msg = I18NUtil.getMessage(
|
String msg = I18NUtil.getMessage(
|
||||||
MSG_UNABLE_TO_CHANGE,
|
MSG_UNABLE_TO_CHANGE,
|
||||||
assocId,
|
assocId,
|
||||||
childNodeName, childNodeNameCrc, entity.getChildNodeNameCrc(),
|
childNodeName, childNodeNameCrc, childNodeNameCrcNew,
|
||||||
qname, qnameCrc, entity.getQnameCrc(),
|
qname, qnameCrc, qnameCrcNew,
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
// We just log this and add details to the message file
|
// We just log this and add details to the message file
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
@@ -289,7 +307,9 @@ public class FixNameCrcValuesPatch extends AbstractPatch
|
|||||||
{
|
{
|
||||||
logger.warn(msg);
|
logger.warn(msg);
|
||||||
}
|
}
|
||||||
writeLine(msg);
|
StringBuilder sb = new StringBuilder(1024);
|
||||||
|
StackTraceUtil.buildStackTrace(msg, e.getStackTrace(), sb, 0);
|
||||||
|
writeLine(sb.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user