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