Fix for ALF-10326 - AVMToADMRemoteStorePatch fails with Duplicate child name not allowed: surf-config

- since fix for ALF-10280 rev 30468 a DuplicateChildNodeNameException no longer automatically retries in the txn - now throw out an exception that does retry instead.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30533 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2011-09-15 10:14:19 +00:00
parent e23edd49d4
commit 127ca27aa0

View File

@@ -51,6 +51,7 @@ import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.DuplicateChildNodeNameException;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.site.SiteInfo;
@@ -60,6 +61,7 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.extensions.surf.util.I18NUtil;
import org.springframework.extensions.surf.util.URLDecoder;
@@ -359,6 +361,8 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
}
NodeRef surfConfigRef;
try
{
if (siteName != null)
{
if (debug) logger.debug("...resolved site id: " + siteName);
@@ -401,6 +405,14 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
if (debug) logger.debug("...resolved generic path.");
surfConfigRef = this.surfConfigRef;
}
}
catch (ConcurrencyFailureException conErr)
{
logger.warn("Unable to create folder: surf-config for path: " + avmNode.getPath() +
" - as another txn is busy, will retry later.");
retryPaths.put(avmNode.getPath(), avmNode);
return;
}
// ensure folders exist down to the specified parent
List<String> folderPath = pathElements.subList(0, pathElements.size() - 1);
@@ -508,10 +520,20 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch
QName assocQName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, SURF_CONFIG);
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(1, 1.0f);
properties.put(ContentModel.PROP_NAME, (Serializable) SURF_CONFIG);
try
{
ChildAssociationRef ref = this.nodeService.createNode(
rootRef, ContentModel.ASSOC_CONTAINS, assocQName, ContentModel.TYPE_FOLDER, properties);
surfConfigRef = ref.getChildRef();
}
catch (DuplicateChildNodeNameException dupErr)
{
// This exception is excepted in multi-threaded creation scenarios - but since fix for
// ALF-10280 rev 30468 - it no longer automatically retries in the txn - therefore we
// throw out an exception that does retry instead.
throw new ConcurrencyFailureException("Forcing batch retry due to DuplicateChildNodeNameException" , dupErr);
}
}
return surfConfigRef;
}