1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.journal.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.kernel.security.permission.ActionKeys;
28  import com.liferay.portal.service.impl.PrincipalBean;
29  import com.liferay.portal.service.permission.PortletPermissionUtil;
30  import com.liferay.portal.util.PortletKeys;
31  import com.liferay.portlet.journal.model.JournalTemplate;
32  import com.liferay.portlet.journal.service.JournalTemplateLocalServiceUtil;
33  import com.liferay.portlet.journal.service.JournalTemplateService;
34  import com.liferay.portlet.journal.service.permission.JournalTemplatePermission;
35  
36  import java.io.File;
37  
38  /**
39   * <a href="JournalTemplateServiceImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * @author Brian Wing Shun Chan
42   *
43   */
44  public class JournalTemplateServiceImpl
45      extends PrincipalBean implements JournalTemplateService {
46  
47      public JournalTemplate addTemplate(
48              String templateId, boolean autoTemplateId, long plid,
49              String structureId, String name, String description, String xsl,
50              boolean formatXsl, String langType, boolean smallImage,
51              String smallImageURL, File smallFile,
52              boolean addCommunityPermissions, boolean addGuestPermissions)
53          throws PortalException, SystemException {
54  
55          PortletPermissionUtil.check(
56              getPermissionChecker(), plid, PortletKeys.JOURNAL,
57              ActionKeys.ADD_TEMPLATE);
58  
59          return JournalTemplateLocalServiceUtil.addTemplate(
60              getUserId(), templateId, autoTemplateId, plid, structureId, name,
61              description, xsl, formatXsl, langType, smallImage, smallImageURL,
62              smallFile, addCommunityPermissions, addGuestPermissions);
63      }
64  
65      public JournalTemplate addTemplate(
66              String templateId, boolean autoTemplateId, long plid,
67              String structureId, String name, String description, String xsl,
68              boolean formatXsl, String langType, boolean smallImage,
69              String smallImageURL, File smallFile, String[] communityPermissions,
70              String[] guestPermissions)
71          throws PortalException, SystemException {
72  
73          PortletPermissionUtil.check(
74              getPermissionChecker(), plid, PortletKeys.JOURNAL,
75              ActionKeys.ADD_TEMPLATE);
76  
77          return JournalTemplateLocalServiceUtil.addTemplate(
78              getUserId(), templateId, autoTemplateId, plid, structureId, name,
79              description, xsl, formatXsl, langType, smallImage, smallImageURL,
80              smallFile, communityPermissions, guestPermissions);
81      }
82  
83      public void deleteTemplate(long groupId, String templateId)
84          throws PortalException, SystemException {
85  
86          JournalTemplatePermission.check(
87              getPermissionChecker(), groupId, templateId, ActionKeys.DELETE);
88  
89          JournalTemplateLocalServiceUtil.deleteTemplate(groupId, templateId);
90      }
91  
92      public JournalTemplate getTemplate(long groupId, String templateId)
93          throws PortalException, SystemException {
94  
95          JournalTemplatePermission.check(
96              getPermissionChecker(), groupId, templateId, ActionKeys.VIEW);
97  
98          return JournalTemplateLocalServiceUtil.getTemplate(groupId, templateId);
99      }
100 
101     public JournalTemplate updateTemplate(
102             long groupId, String templateId, String structureId, String name,
103             String description, String xsl, boolean formatXsl, String langType,
104             boolean smallImage, String smallImageURL, File smallFile)
105         throws PortalException, SystemException {
106 
107         JournalTemplatePermission.check(
108             getPermissionChecker(), groupId, templateId, ActionKeys.UPDATE);
109 
110         return JournalTemplateLocalServiceUtil.updateTemplate(
111             groupId, templateId, structureId, name, description, xsl, formatXsl,
112             langType, smallImage, smallImageURL, smallFile);
113     }
114 
115 }