KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > admin > patch > impl > SavedSearchPermissionPatch


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

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 /**
24  * Grant <b>CONTRIBUTOR</b> role to <b>EVERYONE</b> in <b>savedsearches</b> folder.
25  * <p>
26  * This patch expects the folder to be present.
27  * <p>
28  * JIRA: {@link http://www.alfresco.org/jira/browse/AWC-487 AR-487}
29  *
30  * @see org.alfresco.repo.admin.patch.impl.SavedSearchFolderPatch
31  * @author Derek Hulley
32  */

33 public class SavedSearchPermissionPatch extends SavedSearchFolderPatch
34 {
35     private static final String JavaDoc MSG_CREATED = "patch.savedSearchesPermission.result.applied";
36     private static final String JavaDoc 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 JavaDoc
46     protected String JavaDoc applyInternal() throws Exception JavaDoc
47     {
48         // properties must be set
49
checkCommonProperties();
50         if (permissionService == null)
51         {
52             throw new PatchException("'permissionService' property has not been set");
53         }
54         
55         // get useful values
56
setUp();
57         
58         if (savedSearchesFolderNodeRef == null)
59         {
60             // it doesn't exist
61
String JavaDoc msg = I18NUtil.getMessage(ERR_NOT_FOUND);
62             throw new PatchException(msg);
63         }
64         // apply permission
65
permissionService.setPermission(
66                 savedSearchesFolderNodeRef,
67                 PermissionService.ALL_AUTHORITIES,
68                 PermissionService.CONTRIBUTOR,
69                 true);
70         String JavaDoc msg = I18NUtil.getMessage(MSG_CREATED, savedSearchesFolderNodeRef);
71
72         // done
73
return msg;
74     }
75 }
76
Popular Tags