001
014
015 package com.liferay.portlet.journal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.OrderByComparator;
020 import com.liferay.portal.security.permission.ActionKeys;
021 import com.liferay.portal.service.ServiceContext;
022 import com.liferay.portlet.journal.model.JournalTemplate;
023 import com.liferay.portlet.journal.service.base.JournalTemplateServiceBaseImpl;
024 import com.liferay.portlet.journal.service.permission.JournalPermission;
025 import com.liferay.portlet.journal.service.permission.JournalTemplatePermission;
026
027 import java.io.File;
028
029 import java.util.List;
030 import java.util.Locale;
031 import java.util.Map;
032
033
037 public class JournalTemplateServiceImpl extends JournalTemplateServiceBaseImpl {
038
039 public JournalTemplate addTemplate(
040 long groupId, String templateId, boolean autoTemplateId,
041 String structureId, Map<Locale, String> nameMap,
042 Map<Locale, String> descriptionMap, String xsl, boolean formatXsl,
043 String langType, boolean cacheable, boolean smallImage,
044 String smallImageURL, File smallFile, ServiceContext serviceContext)
045 throws PortalException, SystemException {
046
047 JournalPermission.check(
048 getPermissionChecker(), groupId, ActionKeys.ADD_TEMPLATE);
049
050 return journalTemplateLocalService.addTemplate(
051 getUserId(), groupId, templateId, autoTemplateId, structureId,
052 nameMap, descriptionMap, xsl, formatXsl, langType, cacheable,
053 smallImage, smallImageURL, smallFile, serviceContext);
054 }
055
056 public JournalTemplate addTemplate(
057 long groupId, String templateId, boolean autoTemplateId,
058 String structureId, Map<Locale, String> nameMap,
059 Map<Locale, String> descriptionMap, String xsl, boolean formatXsl,
060 String langType, boolean cacheable, ServiceContext serviceContext)
061 throws PortalException, SystemException {
062
063 JournalPermission.check(
064 getPermissionChecker(), groupId, ActionKeys.ADD_TEMPLATE);
065
066 return journalTemplateLocalService.addTemplate(
067 getUserId(), groupId, templateId, autoTemplateId, structureId,
068 nameMap, descriptionMap, xsl, formatXsl, langType, cacheable, false,
069 null, null, serviceContext);
070 }
071
072 public JournalTemplate copyTemplate(
073 long groupId, String oldTemplateId, String newTemplateId,
074 boolean autoTemplateId)
075 throws PortalException, SystemException {
076
077 JournalPermission.check(
078 getPermissionChecker(), groupId, ActionKeys.ADD_TEMPLATE);
079
080 return journalTemplateLocalService.copyTemplate(
081 getUserId(), groupId, oldTemplateId, newTemplateId, autoTemplateId);
082 }
083
084 public void deleteTemplate(long groupId, String templateId)
085 throws PortalException, SystemException {
086
087 JournalTemplatePermission.check(
088 getPermissionChecker(), groupId, templateId, ActionKeys.DELETE);
089
090 journalTemplateLocalService.deleteTemplate(groupId, templateId);
091 }
092
093 public List<JournalTemplate> getStructureTemplates(
094 long groupId, String structureId)
095 throws SystemException {
096
097 return journalTemplatePersistence.filterFindByG_S(groupId, structureId);
098 }
099
100 public JournalTemplate getTemplate(long groupId, String templateId)
101 throws PortalException, SystemException {
102
103 JournalTemplatePermission.check(
104 getPermissionChecker(), groupId, templateId, ActionKeys.VIEW);
105
106 return journalTemplateLocalService.getTemplate(groupId, templateId);
107 }
108
109 public JournalTemplate getTemplate(
110 long groupId, String templateId, boolean includeGlobalTemplates)
111 throws PortalException, SystemException {
112
113 JournalTemplatePermission.check(
114 getPermissionChecker(), groupId, templateId, ActionKeys.VIEW);
115
116 return journalTemplateLocalService.getTemplate(
117 groupId, templateId, includeGlobalTemplates);
118 }
119
120 public List<JournalTemplate> search(
121 long companyId, long[] groupIds, String keywords,
122 String structureId, String structureIdComparator, int start,
123 int end, OrderByComparator obc)
124 throws SystemException {
125
126 return journalTemplateFinder.filterFindByKeywords(
127 companyId, groupIds, keywords, structureId, structureIdComparator,
128 start, end, obc);
129 }
130
131 public List<JournalTemplate> search(
132 long companyId, long[] groupIds, String templateId,
133 String structureId, String structureIdComparator, String name,
134 String description, boolean andOperator, int start, int end,
135 OrderByComparator obc)
136 throws SystemException {
137
138 return journalTemplateFinder.filterFindByC_G_T_S_N_D(
139 companyId, groupIds, templateId, structureId, structureIdComparator,
140 name, description, andOperator, start, end, obc);
141 }
142
143 public int searchCount(
144 long companyId, long[] groupIds, String keywords,
145 String structureId, String structureIdComparator)
146 throws SystemException {
147
148 return journalTemplateFinder.filterCountByKeywords(
149 companyId, groupIds, keywords, structureId, structureIdComparator);
150 }
151
152 public int searchCount(
153 long companyId, long[] groupIds, String templateId,
154 String structureId, String structureIdComparator, String name,
155 String description, boolean andOperator)
156 throws SystemException {
157
158 return journalTemplateFinder.filterCountByC_G_T_S_N_D(
159 companyId, groupIds, templateId, structureId, structureIdComparator,
160 name, description, andOperator);
161 }
162
163 public JournalTemplate updateTemplate(
164 long groupId, String templateId, String structureId,
165 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
166 String xsl, boolean formatXsl, String langType, boolean cacheable,
167 boolean smallImage, String smallImageURL, File smallFile,
168 ServiceContext serviceContext)
169 throws PortalException, SystemException {
170
171 JournalTemplatePermission.check(
172 getPermissionChecker(), groupId, templateId, ActionKeys.UPDATE);
173
174 return journalTemplateLocalService.updateTemplate(
175 groupId, templateId, structureId, nameMap, descriptionMap, xsl,
176 formatXsl, langType, cacheable, smallImage, smallImageURL,
177 smallFile, serviceContext);
178 }
179
180 public JournalTemplate updateTemplate(
181 long groupId, String templateId, String structureId,
182 Map<Locale, String> nameMap, Map<Locale, String> descriptionMap,
183 String xsl, boolean formatXsl, String langType, boolean cacheable,
184 ServiceContext serviceContext)
185 throws PortalException, SystemException {
186
187 JournalTemplatePermission.check(
188 getPermissionChecker(), groupId, templateId, ActionKeys.UPDATE);
189
190 return journalTemplateLocalService.updateTemplate(
191 groupId, templateId, structureId, nameMap, descriptionMap, xsl,
192 formatXsl, langType, cacheable, false, null, null, serviceContext);
193 }
194
195 }