1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.wiki.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.security.permission.ActionKeys;
20  import com.liferay.portal.service.permission.PortletPermissionUtil;
21  import com.liferay.portal.util.PortletKeys;
22  import com.liferay.portlet.wiki.model.WikiNode;
23  import com.liferay.portlet.wiki.service.base.WikiNodeServiceBaseImpl;
24  import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
25  
26  import java.io.File;
27  
28  import java.util.Map;
29  
30  /**
31   * <a href="WikiNodeServiceImpl.java.html"><b><i>View Source</i></b></a>
32   *
33   * @author Brian Wing Shun Chan
34   * @author Charles May
35   */
36  public class WikiNodeServiceImpl extends WikiNodeServiceBaseImpl {
37  
38      public WikiNode addNode(
39              long plid, String name, String description,
40              boolean addCommunityPermissions, boolean addGuestPermissions)
41          throws PortalException, SystemException {
42  
43          PortletPermissionUtil.check(
44              getPermissionChecker(), plid, PortletKeys.WIKI,
45              ActionKeys.ADD_NODE);
46  
47          return wikiNodeLocalService.addNode(
48              getUserId(), plid, name, description, addCommunityPermissions,
49              addGuestPermissions);
50      }
51  
52      public WikiNode addNode(
53              long plid, String name, String description,
54              String[] communityPermissions, String[] guestPermissions)
55          throws PortalException, SystemException {
56  
57          PortletPermissionUtil.check(
58              getPermissionChecker(), plid, PortletKeys.WIKI,
59              ActionKeys.ADD_NODE);
60  
61          return wikiNodeLocalService.addNode(
62              getUserId(), plid, name, description, communityPermissions,
63              guestPermissions);
64      }
65  
66      public void deleteNode(long nodeId)
67          throws PortalException, SystemException {
68  
69          WikiNodePermission.check(
70              getPermissionChecker(), nodeId, ActionKeys.DELETE);
71  
72          wikiNodeLocalService.deleteNode(nodeId);
73      }
74  
75      public WikiNode getNode(long nodeId)
76          throws PortalException, SystemException {
77  
78          WikiNodePermission.check(
79              getPermissionChecker(), nodeId, ActionKeys.VIEW);
80  
81          return wikiNodeLocalService.getNode(nodeId);
82      }
83  
84      public WikiNode getNode(long groupId, String name)
85          throws PortalException, SystemException {
86  
87          WikiNodePermission.check(
88              getPermissionChecker(), groupId, name, ActionKeys.VIEW);
89  
90          return wikiNodeLocalService.getNode(groupId, name);
91      }
92  
93      public void importPages(
94              long nodeId, String importer, File[] files,
95              Map<String, String[]> options)
96          throws PortalException, SystemException {
97  
98          WikiNodePermission.check(
99              getPermissionChecker(), nodeId, ActionKeys.IMPORT);
100 
101         wikiNodeLocalService.importPages(
102             getUserId(), nodeId, importer, files, options);
103     }
104 
105     public void subscribeNode(long nodeId)
106         throws PortalException, SystemException {
107 
108         WikiNodePermission.check(
109             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
110 
111         wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
112     }
113 
114     public void unsubscribeNode(long nodeId)
115         throws PortalException, SystemException {
116 
117         WikiNodePermission.check(
118             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
119 
120         wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
121     }
122 
123     public WikiNode updateNode(long nodeId, String name, String description)
124         throws PortalException, SystemException {
125 
126         WikiNodePermission.check(
127             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
128 
129         return wikiNodeLocalService.updateNode(nodeId, name, description);
130     }
131 
132 }