1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.wiki.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.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     public WikiNode updateNode(long nodeId, String name, String description)
108         throws PortalException, SystemException {
109 
110         WikiNodePermission.check(
111             getPermissionChecker(), nodeId, ActionKeys.UPDATE);
112 
113         return wikiNodeLocalService.updateNode(nodeId, name, description);
114     }
115 
116 }