diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index 54dc3db59c..9e0533ce41 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -435,6 +435,7 @@ patch.nodeTemplatesFolder.description=Patch to create new Data Dictionary folder patch.sitesSpacePermissions.description=Patch to remove the EVERYONE Contributor permissions on the Sites Space (parent container of all Sites) patch.sitesSpacePermissions.result=Permissions corrected. +patch.sitesSpacePermissions.result.none=Permissions corrections not required. patch.updateWorkflowNotificationTemplates.description=Patch to update the workflow notification templates. patch.updateWorkflowNotificationTemplates.result=Workflow Notification Templates successfully updated. diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 53b453823e..31ffc00c61 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -2918,11 +2918,6 @@ 0 5011 5012 - - - - - false @@ -3044,11 +3039,6 @@ 0 5017 5018 - - - - - true true diff --git a/source/java/org/alfresco/repo/admin/patch/impl/SitesSpacePermissionsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/SitesSpacePermissionsPatch.java index dbd2a84065..98cbeede05 100644 --- a/source/java/org/alfresco/repo/admin/patch/impl/SitesSpacePermissionsPatch.java +++ b/source/java/org/alfresco/repo/admin/patch/impl/SitesSpacePermissionsPatch.java @@ -44,13 +44,13 @@ public class SitesSpacePermissionsPatch extends AbstractPatch { // Message IDs private static final String MSG_SUCCESS = "patch.sitesSpacePermissions.result"; + private static final String MSG_SUCCESS_NONE = "patch.sitesSpacePermissions.result.none"; // Folders' names for path building private static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname"; private static final String PROPERTY_SITES_CHILDNAME = "spaces.sites.childname"; // Things we've found - private NodeRef companyHomeNodeRef; private NodeRef sitesNodeRef; // Dependencies @@ -102,27 +102,13 @@ public class SitesSpacePermissionsPatch extends AbstractPatch throw new PatchException("Bootstrap property '" + PROPERTY_SITES_CHILDNAME + "' is not present"); } - // Build the search string to get the company home node + // build the search string to get the sites node StringBuilder sb = new StringBuilder(256); sb.append("/").append(companyHomeChildName); - String xpath = sb.toString(); - // get the company home - List nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false); - if (nodeRefs.size() == 0) - { - throw new PatchException("XPath didn't return any results: \n" + " root: " + storeRootNodeRef + "\n" + " xpath: " + xpath); - } - else if (nodeRefs.size() > 1) - { - throw new PatchException("XPath returned too many results: \n" + " root: " + storeRootNodeRef + "\n" + " xpath: " + xpath + "\n" + " results: " + nodeRefs); - } - this.companyHomeNodeRef = nodeRefs.get(0); - - // build the search string to get the sites node sb.append("/").append(sitesChildName); - xpath = sb.toString(); + String xpath = sb.toString(); // get the sites node - nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false); + List nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false); if (nodeRefs.size() == 0) { throw new PatchException("XPath didn't return any results: \n" + " root: " + storeRootNodeRef + "\n" + " xpath: " + xpath); @@ -146,15 +132,28 @@ public class SitesSpacePermissionsPatch extends AbstractPatch throw new IllegalStateException("Sites Space not found in Company Home!"); } - // Remove the permission - permissionService.deletePermission( - sitesSpace, - PermissionService.ALL_AUTHORITIES, - PermissionService.CONTRIBUTOR - ); + String msg = I18NUtil.getMessage(MSG_SUCCESS); + try + { + // Remove the permission + permissionService.deletePermission( + sitesSpace, + PermissionService.ALL_AUTHORITIES, + PermissionService.CONTRIBUTOR + ); + } + catch (IllegalStateException e) + { + if (e.getMessage().contains("SHARED")) + { + // ALF-11489: 'patch.sitesSpacePermissions' failed on upgrade 2.2.8 -> 3.4.6 + // We are catching "Can not delete from this acl in a node context SHARED" + msg = I18NUtil.getMessage(MSG_SUCCESS_NONE); + } + // Something else + } // All done - String msg = I18NUtil.getMessage(MSG_SUCCESS); return msg; } }