1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.wiki.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.security.permission.ActionKeys;
28  import com.liferay.portal.service.permission.PortletPermissionUtil;
29  import com.liferay.portal.util.PortletKeys;
30  import com.liferay.portlet.wiki.model.WikiNode;
31  import com.liferay.portlet.wiki.service.base.WikiNodeServiceBaseImpl;
32  import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
33  
34  import java.io.File;
35  
36  import java.util.Map;
37  
38  /**
39   * <a href="WikiNodeServiceImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * @author Brian Wing Shun Chan
42   * @author Charles May
43   *
44   */
45  public class WikiNodeServiceImpl extends WikiNodeServiceBaseImpl {
46  
47      public WikiNode addNode(
48              long plid, String name, String description,
49              boolean addCommunityPermissions, boolean addGuestPermissions)
50          throws PortalException, SystemException {
51  
52          PortletPermissionUtil.check(
53              getPermissionChecker(), plid, PortletKeys.WIKI,
54              ActionKeys.ADD_NODE);
55  
56          return wikiNodeLocalService.addNode(
57              getUserId(), plid, name, description, addCommunityPermissions,
58              addGuestPermissions);
59      }
60  
61      public WikiNode addNode(
62              long plid, String name, String description,
63              String[] communityPermissions, String[] guestPermissions)
64          throws PortalException, SystemException {
65  
66          PortletPermissionUtil.check(
67              getPermissionChecker(), plid, PortletKeys.WIKI,
68              ActionKeys.ADD_NODE);
69  
70          return wikiNodeLocalService.addNode(
71              getUserId(), plid, name, description, communityPermissions,
72              guestPermissions);
73      }
74  
75      public void deleteNode(long nodeId)
76          throws PortalException, SystemException {
77  
78          WikiNodePermission.check(
79              getPermissionChecker(), nodeId, ActionKeys.DELETE);
80  
81          wikiNodeLocalService.deleteNode(nodeId);
82      }
83  
84      public WikiNode getNode(long nodeId)
85          throws PortalException, SystemException {
86  
87          WikiNodePermission.check(
88              getPermissionChecker(), nodeId, ActionKeys.VIEW);
89  
90          return wikiNodeLocalService.getNode(nodeId);
91      }
92  
93      public WikiNode getNode(long groupId, String name)
94          throws PortalException, SystemException {
95  
96          WikiNodePermission.check(
97              getPermissionChecker(), groupId, name, ActionKeys.VIEW);
98  
99          return wikiNodeLocalService.getNode(groupId, name);
100     }
101 
102     public void importPages(
103             long nodeId, String importer, File[] files,
104             Map<String, String[]> options)
105         throws PortalException, SystemException {
106 
107         WikiNodePermission.check(
108             getPermissionChecker(), nodeId, ActionKeys.IMPORT);
109 
110         wikiNodeLocalService.importPages(
111             getUserId(), nodeId, importer, files, options);
112     }
113 
114     public void subscribeNode(long nodeId)
115         throws PortalException, SystemException {
116 
117         WikiNodePermission.check(
118             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
119 
120         wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
121     }
122 
123     public void unsubscribeNode(long nodeId)
124         throws PortalException, SystemException {
125 
126         WikiNodePermission.check(
127             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
128 
129         wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
130     }
131 
132     public WikiNode updateNode(long nodeId, String name, String description)
133         throws PortalException, SystemException {
134 
135         WikiNodePermission.check(
136             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
137 
138         return wikiNodeLocalService.updateNode(nodeId, name, description);
139     }
140 
141 }