001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.wiki.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.ServiceContext;
021    import com.liferay.portlet.wiki.model.WikiNode;
022    import com.liferay.portlet.wiki.service.base.WikiNodeServiceBaseImpl;
023    import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
024    import com.liferay.portlet.wiki.service.permission.WikiPermission;
025    
026    import java.io.InputStream;
027    
028    import java.util.Map;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     * @author Charles May
033     */
034    public class WikiNodeServiceImpl extends WikiNodeServiceBaseImpl {
035    
036            @Override
037            public WikiNode addNode(
038                            String name, String description, ServiceContext serviceContext)
039                    throws PortalException, SystemException {
040    
041                    WikiPermission.check(
042                            getPermissionChecker(), serviceContext.getScopeGroupId(),
043                            ActionKeys.ADD_NODE);
044    
045                    return wikiNodeLocalService.addNode(
046                            getUserId(), name, description, serviceContext);
047            }
048    
049            @Override
050            public void deleteNode(long nodeId)
051                    throws PortalException, SystemException {
052    
053                    WikiNodePermission.check(
054                            getPermissionChecker(), nodeId, ActionKeys.DELETE);
055    
056                    wikiNodeLocalService.deleteNode(nodeId);
057            }
058    
059            @Override
060            public WikiNode getNode(long nodeId)
061                    throws PortalException, SystemException {
062    
063                    WikiNodePermission.check(
064                            getPermissionChecker(), nodeId, ActionKeys.VIEW);
065    
066                    return wikiNodeLocalService.getNode(nodeId);
067            }
068    
069            @Override
070            public WikiNode getNode(long groupId, String name)
071                    throws PortalException, SystemException {
072    
073                    WikiNodePermission.check(
074                            getPermissionChecker(), groupId, name, ActionKeys.VIEW);
075    
076                    return wikiNodeLocalService.getNode(groupId, name);
077            }
078    
079            @Override
080            public void importPages(
081                            long nodeId, String importer, InputStream[] inputStreams,
082                            Map<String, String[]> options)
083                    throws PortalException, SystemException {
084    
085                    WikiNodePermission.check(
086                            getPermissionChecker(), nodeId, ActionKeys.IMPORT);
087    
088                    wikiNodeLocalService.importPages(
089                            getUserId(), nodeId, importer, inputStreams, options);
090            }
091    
092            @Override
093            public void subscribeNode(long nodeId)
094                    throws PortalException, SystemException {
095    
096                    WikiNodePermission.check(
097                            getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
098    
099                    wikiNodeLocalService.subscribeNode(getUserId(), nodeId);
100            }
101    
102            @Override
103            public void unsubscribeNode(long nodeId)
104                    throws PortalException, SystemException {
105    
106                    WikiNodePermission.check(
107                            getPermissionChecker(), nodeId, ActionKeys.SUBSCRIBE);
108    
109                    wikiNodeLocalService.unsubscribeNode(getUserId(), nodeId);
110            }
111    
112            @Override
113            public WikiNode updateNode(
114                            long nodeId, String name, String description,
115                            ServiceContext serviceContext)
116                    throws PortalException, SystemException {
117    
118                    WikiNodePermission.check(
119                            getPermissionChecker(), nodeId, ActionKeys.UPDATE);
120    
121                    return wikiNodeLocalService.updateNode(
122                            nodeId, name, description, serviceContext);
123            }
124    
125    }