diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index cf3fa02ba4..f33888d2b7 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -408,3 +408,6 @@ patch.exampleJavaScript.description=Loads sample Javascript file into datadictio patch.fixAclInheritance.description=Fixes any ACL inheritance issues. patch.fixAclInheritance.result=Fixed {0} ACLs. + +patch.avmToAdmRemoteStore.description=Migrates Share Surf config from AVM sitestore to DM Sites folder. +patch.avmToAdmRemoteStore.complete=Completed Share Surf config migration. diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 831b521968..6ac042d986 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -2691,11 +2691,6 @@ - - - alfresco/bootstrap/team-sample-sites/swsdp/AVM.zip - - alfresco/bootstrap/team-sample-sites/swsdp/Users.acp @@ -2864,4 +2859,21 @@ - + + + patch.avmToAdmRemoteStore + patch.avmToAdmRemoteStore.description + 0 + 5011 + 5012 + false + + + + + + sitestore + /alfresco/site-data + + + \ No newline at end of file diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties index 93bd254927..cb8aa75949 100644 --- a/config/alfresco/version.properties +++ b/config/alfresco/version.properties @@ -19,4 +19,4 @@ version.build=@build-number@ # Schema number -version.schema=5011 +version.schema=5012 diff --git a/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java b/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java index 537530b89b..d75bb56306 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/AVMToADMRemoteStorePatch.java @@ -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.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.site.SiteInfo; import org.alfresco.service.cmr.site.SiteService; @@ -402,18 +403,18 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch } // ensure folders exist down to the specified parent + List folderPath = pathElements.subList(0, pathElements.size() - 1); NodeRef parentFolder = null; Pair lastFolderCache = this.lastFolderCache.get(); - String folderKey = (siteName != null) ? siteName + path : path; + String folderKey = (siteName != null) ? siteName + folderPath.toString() : folderPath.toString(); if (folderKey.equals(lastFolderCache.getFirst())) { // found match to last used folder NodeRef - if (debug) logger.debug("...cache hit - matched last folder reference."); + if (debug) logger.debug("...cache hit - matched last folder reference: " + folderKey); parentFolder = lastFolderCache.getSecond(); } if (parentFolder == null) { - List folderPath = pathElements.subList(0, pathElements.size() - 1); try { parentFolder = FileFolderUtil.makeFolders( @@ -436,32 +437,43 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch lastFolderCache.setSecond(parentFolder); } - if (userId != null) + try { - // run as the appropriate user id to execute - final NodeRef parentFolderRef = parentFolder; - AuthenticationUtil.runAs(new RunAsWork() + if (userId != null) { - public Void doWork() throws Exception + // run as the appropriate user id to execute + final NodeRef parentFolderRef = parentFolder; + AuthenticationUtil.runAs(new RunAsWork() { - // create new node and perform writer content copy of the content from the AVM to the DM store - FileInfo fileInfo = fileFolderService.create( - parentFolderRef, avmNode.getName(), ContentModel.TYPE_CONTENT); - ContentWriter writer = contentService.getWriter( - fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); - writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); - return null; - } - }, userId); + public Void doWork() throws Exception + { + // create new node and perform writer content copy of the content from the AVM to the DM store + FileInfo fileInfo = fileFolderService.create( + parentFolderRef, avmNode.getName(), ContentModel.TYPE_CONTENT); + ContentWriter writer = contentService.getWriter( + fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); + writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); + return null; + } + }, userId); + } + else + { + // create new node and perform writer content copy of the content from the AVM to the DM store + FileInfo fileInfo = fileFolderService.create( + parentFolder, avmNode.getName(), ContentModel.TYPE_CONTENT); + ContentWriter writer = contentService.getWriter( + fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); + writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); + } } - else + catch (InvalidNodeRefException refErr) { - // create new node and perform writer content copy of the content from the AVM to the DM store - FileInfo fileInfo = fileFolderService.create( - parentFolder, avmNode.getName(), ContentModel.TYPE_CONTENT); - ContentWriter writer = contentService.getWriter( - fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true); - writer.putContent(avmService.getContentReader(-1, avmNode.getPath())); + // this occurs if a different thread running a separate txn has not yet created a folder + // that we expected to exist - save a reference to this path to retry it again later + logger.warn("Parent folder does not exist yet: " + refErr.getNodeRef() + " for path: " + avmNode.getPath() + + " - as another txn is busy, will retry later."); + retryPaths.put(avmNode.getPath(), avmNode); } } } @@ -535,6 +547,10 @@ public class AVMToADMRemoteStorePatch extends AbstractPatch { if (debug) logger.debug("...adding path: " + n.getPath()); paths.put(n.getPath(), n); + if (paths.size() % 10000 == 0) + { + logger.info("Collected " + paths.size() + " AVM paths..."); + } } else if (n.isDirectory()) {