1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.wiki.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portal.service.permission.PortletPermissionUtil;
26  import com.liferay.portal.util.PortletKeys;
27  import com.liferay.portlet.wiki.model.WikiNode;
28  import com.liferay.portlet.wiki.service.base.WikiNodeServiceBaseImpl;
29  import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
30  
31  import java.io.File;
32  
33  import java.util.Map;
34  
35  /**
36   * <a href="WikiNodeServiceImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Brian Wing Shun Chan
39   * @author Charles May
40   *
41   */
42  public class WikiNodeServiceImpl extends WikiNodeServiceBaseImpl {
43  
44      public WikiNode addNode(
45              long plid, String name, String description,
46              boolean addCommunityPermissions, boolean addGuestPermissions)
47          throws PortalException, SystemException {
48  
49          PortletPermissionUtil.check(
50              getPermissionChecker(), plid, PortletKeys.WIKI,
51              ActionKeys.ADD_NODE);
52  
53          return wikiNodeLocalService.addNode(
54              getUserId(), plid, name, description, addCommunityPermissions,
55              addGuestPermissions);
56      }
57  
58      public WikiNode addNode(
59              long plid, String name, String description,
60              String[] communityPermissions, String[] guestPermissions)
61          throws PortalException, SystemException {
62  
63          PortletPermissionUtil.check(
64              getPermissionChecker(), plid, PortletKeys.WIKI,
65              ActionKeys.ADD_NODE);
66  
67          return wikiNodeLocalService.addNode(
68              getUserId(), plid, name, description, communityPermissions,
69              guestPermissions);
70      }
71  
72      public void deleteNode(long nodeId)
73          throws PortalException, SystemException {
74  
75          WikiNodePermission.check(
76              getPermissionChecker(), nodeId, ActionKeys.DELETE);
77  
78          wikiNodeLocalService.deleteNode(nodeId);
79      }
80  
81      public WikiNode getNode(long nodeId)
82          throws PortalException, SystemException {
83  
84          WikiNodePermission.check(
85              getPermissionChecker(), nodeId, ActionKeys.VIEW);
86  
87          return wikiNodeLocalService.getNode(nodeId);
88      }
89  
90      public WikiNode getNode(long groupId, String name)
91          throws PortalException, SystemException {
92  
93          WikiNodePermission.check(
94              getPermissionChecker(), groupId, name, ActionKeys.VIEW);
95  
96          return wikiNodeLocalService.getNode(groupId, name);
97      }
98  
99      public void importPages(
100             long nodeId, String importer, File[] files,
101             Map<String, String[]> options)
102         throws PortalException, SystemException {
103 
104         WikiNodePermission.check(
105             getPermissionChecker(), nodeId, ActionKeys.IMPORT);
106 
107         wikiNodeLocalService.importPages(
108             getUserId(), nodeId, importer, files, options);
109     }
110 
111     public void subscribeNode(long nodeId)
112         throws PortalException, SystemException {
113 
114         WikiNodePermission.check(
115             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
116 
117         wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
118     }
119 
120     public void unsubscribeNode(long nodeId)
121         throws PortalException, SystemException {
122 
123         WikiNodePermission.check(
124             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
125 
126         wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
127     }
128 
129     public WikiNode updateNode(long nodeId, String name, String description)
130         throws PortalException, SystemException {
131 
132         WikiNodePermission.check(
133             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
134 
135         return wikiNodeLocalService.updateNode(nodeId, name, description);
136     }
137 
138 }