1 17 package org.alfresco.repo.admin.patch.impl; 18 19 import org.alfresco.i18n.I18NUtil; 20 import org.alfresco.service.cmr.admin.PatchException; 21 import org.alfresco.service.cmr.security.PermissionService; 22 23 33 public class SavedSearchPermissionPatch extends SavedSearchFolderPatch 34 { 35 private static final String MSG_CREATED = "patch.savedSearchesPermission.result.applied"; 36 private static final String ERR_NOT_FOUND = "patch.savedSearchesPermission.err.not_found"; 37 38 private PermissionService permissionService; 39 40 public void setPermissionService(PermissionService permissionService) 41 { 42 this.permissionService = permissionService; 43 } 44 45 @Override 46 protected String applyInternal() throws Exception 47 { 48 checkCommonProperties(); 50 if (permissionService == null) 51 { 52 throw new PatchException("'permissionService' property has not been set"); 53 } 54 55 setUp(); 57 58 if (savedSearchesFolderNodeRef == null) 59 { 60 String msg = I18NUtil.getMessage(ERR_NOT_FOUND); 62 throw new PatchException(msg); 63 } 64 permissionService.setPermission( 66 savedSearchesFolderNodeRef, 67 PermissionService.ALL_AUTHORITIES, 68 PermissionService.CONTRIBUTOR, 69 true); 70 String msg = I18NUtil.getMessage(MSG_CREATED, savedSearchesFolderNodeRef); 71 72 return msg; 74 } 75 } 76 | Popular Tags |