1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.journal.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.security.permission.ActionKeys;
25  import com.liferay.portal.service.permission.PortletPermissionUtil;
26  import com.liferay.portal.util.PortletKeys;
27  import com.liferay.portlet.journal.model.JournalStructure;
28  import com.liferay.portlet.journal.service.base.JournalStructureServiceBaseImpl;
29  import com.liferay.portlet.journal.service.permission.JournalStructurePermission;
30  
31  /**
32   * <a href="JournalStructureServiceImpl.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class JournalStructureServiceImpl
38      extends JournalStructureServiceBaseImpl {
39  
40      public JournalStructure addStructure(
41              String structureId, boolean autoStructureId, long plid, String name,
42              String description, String xsd, boolean addCommunityPermissions,
43              boolean addGuestPermissions)
44          throws PortalException, SystemException {
45  
46          PortletPermissionUtil.check(
47              getPermissionChecker(), plid, PortletKeys.JOURNAL,
48              ActionKeys.ADD_STRUCTURE);
49  
50          return journalStructureLocalService.addStructure(
51              getUserId(), structureId, autoStructureId, plid, name, description,
52              xsd, addCommunityPermissions, addGuestPermissions);
53      }
54  
55      public JournalStructure addStructure(
56              String structureId, boolean autoStructureId, long plid, String name,
57              String description, String xsd, String[] communityPermissions,
58              String[] guestPermissions)
59          throws PortalException, SystemException {
60  
61          PortletPermissionUtil.check(
62              getPermissionChecker(), plid, PortletKeys.JOURNAL,
63              ActionKeys.ADD_STRUCTURE);
64  
65          return journalStructureLocalService.addStructure(
66              getUserId(), structureId, autoStructureId, plid, name, description,
67              xsd, communityPermissions, guestPermissions);
68      }
69  
70      public JournalStructure copyStructure(
71              long groupId, String oldStructureId, String newStructureId,
72              boolean autoStructureId)
73          throws PortalException, SystemException {
74  
75          JournalStructurePermission.check(
76              getPermissionChecker(), groupId, oldStructureId,
77              ActionKeys.ADD_STRUCTURE);
78  
79          return journalStructureLocalService.copyStructure(
80              getUserId(), groupId, oldStructureId, newStructureId,
81              autoStructureId);
82      }
83  
84      public void deleteStructure(long groupId, String structureId)
85          throws PortalException, SystemException {
86  
87          JournalStructurePermission.check(
88              getPermissionChecker(), groupId, structureId, ActionKeys.DELETE);
89  
90          journalStructureLocalService.deleteStructure(groupId, structureId);
91      }
92  
93      public JournalStructure getStructure(long groupId, String structureId)
94          throws PortalException, SystemException {
95  
96          JournalStructurePermission.check(
97              getPermissionChecker(), groupId, structureId, ActionKeys.VIEW);
98  
99          return journalStructureLocalService.getStructure(groupId, structureId);
100     }
101 
102     public JournalStructure updateStructure(
103             long groupId, String structureId, String name, String description,
104             String xsd)
105         throws PortalException, SystemException {
106 
107         JournalStructurePermission.check(
108             getPermissionChecker(), groupId, structureId, ActionKeys.UPDATE);
109 
110         return journalStructureLocalService.updateStructure(
111             groupId, structureId, name, description, xsd);
112     }
113 
114 }