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.ServiceContext;
21  import com.liferay.portlet.wiki.model.WikiNode;
22  import com.liferay.portlet.wiki.service.base.WikiNodeServiceBaseImpl;
23  import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
24  import com.liferay.portlet.wiki.service.permission.WikiPermission;
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              String name, String description, ServiceContext serviceContext)
40          throws PortalException, SystemException {
41  
42          WikiPermission.check(
43              getPermissionChecker(), serviceContext.getScopeGroupId(),
44              ActionKeys.ADD_NODE);
45  
46          return wikiNodeLocalService.addNode(
47              getUserId(), name, description, serviceContext);
48      }
49  
50      public void deleteNode(long nodeId)
51          throws PortalException, SystemException {
52  
53          WikiNodePermission.check(
54              getPermissionChecker(), nodeId, ActionKeys.DELETE);
55  
56          wikiNodeLocalService.deleteNode(nodeId);
57      }
58  
59      public WikiNode getNode(long nodeId)
60          throws PortalException, SystemException {
61  
62          WikiNodePermission.check(
63              getPermissionChecker(), nodeId, ActionKeys.VIEW);
64  
65          return wikiNodeLocalService.getNode(nodeId);
66      }
67  
68      public WikiNode getNode(long groupId, String name)
69          throws PortalException, SystemException {
70  
71          WikiNodePermission.check(
72              getPermissionChecker(), groupId, name, ActionKeys.VIEW);
73  
74          return wikiNodeLocalService.getNode(groupId, name);
75      }
76  
77      public void importPages(
78              long nodeId, String importer, File[] files,
79              Map<String, String[]> options)
80          throws PortalException, SystemException {
81  
82          WikiNodePermission.check(
83              getPermissionChecker(), nodeId, ActionKeys.IMPORT);
84  
85          wikiNodeLocalService.importPages(
86              getUserId(), nodeId, importer, files, options);
87      }
88  
89      public void subscribeNode(long nodeId)
90          throws PortalException, SystemException {
91  
92          WikiNodePermission.check(
93              getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
94  
95          wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
96      }
97  
98      public void unsubscribeNode(long nodeId)
99          throws PortalException, SystemException {
100 
101         WikiNodePermission.check(
102             getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
103 
104         wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
105     }
106 
107     /**
108      * @deprecated
109      */
110     public WikiNode updateNode(long nodeId, String name, String description)
111         throws PortalException, SystemException {
112 
113         WikiNodePermission.check(
114             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
115 
116         return wikiNodeLocalService.updateNode(nodeId, name, description);
117     }
118 
119     public WikiNode updateNode(
120             long nodeId, String name, String description,
121             ServiceContext serviceContext)
122         throws PortalException, SystemException {
123 
124         WikiNodePermission.check(
125             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
126 
127         return wikiNodeLocalService.updateNode(
128             nodeId, name, description, serviceContext);
129     }
130 
131 }