1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class WikiNodeServiceImpl extends WikiNodeServiceBaseImpl {
45  
46      public WikiNode addNode(
47              long plid, String name, String description,
48              boolean addCommunityPermissions, boolean addGuestPermissions)
49          throws PortalException, SystemException {
50  
51          PortletPermissionUtil.check(
52              getPermissionChecker(), plid, PortletKeys.WIKI,
53              ActionKeys.ADD_NODE);
54  
55          return wikiNodeLocalService.addNode(
56              getUserId(), plid, name, description, addCommunityPermissions,
57              addGuestPermissions);
58      }
59  
60      public WikiNode addNode(
61              long plid, String name, String description,
62              String[] communityPermissions, String[] guestPermissions)
63          throws PortalException, SystemException {
64  
65          PortletPermissionUtil.check(
66              getPermissionChecker(), plid, PortletKeys.WIKI,
67              ActionKeys.ADD_NODE);
68  
69          return wikiNodeLocalService.addNode(
70              getUserId(), plid, name, description, communityPermissions,
71              guestPermissions);
72      }
73  
74      public void deleteNode(long nodeId)
75          throws PortalException, SystemException {
76  
77          WikiNodePermission.check(
78              getPermissionChecker(), nodeId, ActionKeys.DELETE);
79  
80          wikiNodeLocalService.deleteNode(nodeId);
81      }
82  
83      public WikiNode getNode(long nodeId)
84          throws PortalException, SystemException {
85  
86          WikiNodePermission.check(
87              getPermissionChecker(), nodeId, ActionKeys.VIEW);
88  
89          return wikiNodeLocalService.getNode(nodeId);
90      }
91  
92      public WikiNode getNode(long groupId, String name)
93          throws PortalException, SystemException {
94  
95          WikiNodePermission.check(
96              getPermissionChecker(), groupId, name, ActionKeys.VIEW);
97  
98          return wikiNodeLocalService.getNode(groupId, name);
99      }
100 
101     public void importPages(
102             long nodeId, String importer, File[] files,
103             Map<String, String[]> options)
104         throws PortalException, SystemException {
105 
106         WikiNodePermission.check(
107             getPermissionChecker(), nodeId, ActionKeys.IMPORT);
108 
109         wikiNodeLocalService.importPages(
110             getUserId(), nodeId, importer, files, options);
111     }
112 
113     public void subscribeNode(long nodeId)
114         throws PortalException, SystemException {
115 
116         WikiNodePermission.check(
117             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
118 
119         wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
120     }
121 
122     public void unsubscribeNode(long nodeId)
123         throws PortalException, SystemException {
124 
125         WikiNodePermission.check(
126             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
127 
128         wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
129     }
130 
131     public WikiNode updateNode(long nodeId, String name, String description)
132         throws PortalException, SystemException {
133 
134         WikiNodePermission.check(
135             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
136 
137         return wikiNodeLocalService.updateNode(nodeId, name, description);
138     }
139 
140 }