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.portal.theme.ThemeDisplay;
023 import com.liferay.portlet.journal.model.JournalArticle;
024 import com.liferay.portlet.journal.model.JournalArticleConstants;
025 import com.liferay.portlet.journal.service.base.JournalArticleServiceBaseImpl;
026 import com.liferay.portlet.journal.service.permission.JournalArticlePermission;
027 import com.liferay.portlet.journal.service.permission.JournalPermission;
028
029 import java.io.File;
030
031 import java.util.Date;
032 import java.util.List;
033 import java.util.Locale;
034 import java.util.Map;
035
036
040 public class JournalArticleServiceImpl extends JournalArticleServiceBaseImpl {
041
042 @Override
043 public JournalArticle addArticle(
044 long groupId, long classNameId, long classPK, String articleId,
045 boolean autoArticleId, Map<Locale, String> titleMap,
046 Map<Locale, String> descriptionMap, String content, String type,
047 String structureId, String templateId, String layoutUuid,
048 int displayDateMonth, int displayDateDay, int displayDateYear,
049 int displayDateHour, int displayDateMinute, int expirationDateMonth,
050 int expirationDateDay, int expirationDateYear,
051 int expirationDateHour, int expirationDateMinute,
052 boolean neverExpire, int reviewDateMonth, int reviewDateDay,
053 int reviewDateYear, int reviewDateHour, int reviewDateMinute,
054 boolean neverReview, boolean indexable, boolean smallImage,
055 String smallImageURL, File smallFile, Map<String, byte[]> images,
056 String articleURL, ServiceContext serviceContext)
057 throws PortalException, SystemException {
058
059 JournalPermission.check(
060 getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
061
062 return journalArticleLocalService.addArticle(
063 getUserId(), groupId, classNameId, classPK, articleId,
064 autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap,
065 descriptionMap, content, type, structureId, templateId, layoutUuid,
066 displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
067 displayDateMinute, expirationDateMonth, expirationDateDay,
068 expirationDateYear, expirationDateHour, expirationDateMinute,
069 neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear,
070 reviewDateHour, reviewDateMinute, neverReview, indexable,
071 smallImage, smallImageURL, smallFile, images, articleURL,
072 serviceContext);
073 }
074
075 @Override
076 public JournalArticle addArticle(
077 long groupId, long classNameId, long classPK, String articleId,
078 boolean autoArticleId, Map<Locale, String> titleMap,
079 Map<Locale, String> descriptionMap, String content, String type,
080 String structureId, String templateId, String layoutUuid,
081 int displayDateMonth, int displayDateDay, int displayDateYear,
082 int displayDateHour, int displayDateMinute, int expirationDateMonth,
083 int expirationDateDay, int expirationDateYear,
084 int expirationDateHour, int expirationDateMinute,
085 boolean neverExpire, int reviewDateMonth, int reviewDateDay,
086 int reviewDateYear, int reviewDateHour, int reviewDateMinute,
087 boolean neverReview, boolean indexable, String articleURL,
088 ServiceContext serviceContext)
089 throws PortalException, SystemException {
090
091 JournalPermission.check(
092 getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
093
094 return journalArticleLocalService.addArticle(
095 getUserId(), groupId, classNameId, classPK, articleId,
096 autoArticleId, JournalArticleConstants.VERSION_DEFAULT, titleMap,
097 descriptionMap, content, type, structureId, templateId, layoutUuid,
098 displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
099 displayDateMinute, expirationDateMonth, expirationDateDay,
100 expirationDateYear, expirationDateHour, expirationDateMinute,
101 neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear,
102 reviewDateHour, reviewDateMinute, neverReview, indexable, false,
103 null, null, null, articleURL, serviceContext);
104 }
105
106 @Override
107 public JournalArticle copyArticle(
108 long groupId, String oldArticleId, String newArticleId,
109 boolean autoArticleId, double version)
110 throws PortalException, SystemException {
111
112 JournalPermission.check(
113 getPermissionChecker(), groupId, ActionKeys.ADD_ARTICLE);
114
115 return journalArticleLocalService.copyArticle(
116 getUserId(), groupId, oldArticleId, newArticleId, autoArticleId,
117 version);
118 }
119
120 @Override
121 public void deleteArticle(
122 long groupId, String articleId, double version, String articleURL,
123 ServiceContext serviceContext)
124 throws PortalException, SystemException {
125
126 JournalArticlePermission.check(
127 getPermissionChecker(), groupId, articleId, version,
128 ActionKeys.DELETE);
129
130 journalArticleLocalService.deleteArticle(
131 groupId, articleId, version, articleURL, serviceContext);
132 }
133
134 @Override
135 public void deleteArticle(
136 long groupId, String articleId, String articleURL,
137 ServiceContext serviceContext)
138 throws PortalException, SystemException {
139
140 JournalArticlePermission.check(
141 getPermissionChecker(), groupId, articleId, ActionKeys.DELETE);
142
143 journalArticleLocalService.deleteArticle(
144 groupId, articleId, serviceContext);
145 }
146
147 @Override
148 public JournalArticle expireArticle(
149 long groupId, String articleId, double version, String articleURL,
150 ServiceContext serviceContext)
151 throws PortalException, SystemException {
152
153 JournalArticlePermission.check(
154 getPermissionChecker(), groupId, articleId, version,
155 ActionKeys.EXPIRE);
156
157 return journalArticleLocalService.expireArticle(
158 getUserId(), groupId, articleId, version, articleURL,
159 serviceContext);
160 }
161
162 @Override
163 public void expireArticle(
164 long groupId, String articleId, String articleURL,
165 ServiceContext serviceContext)
166 throws PortalException, SystemException {
167
168 JournalArticlePermission.check(
169 getPermissionChecker(), groupId, articleId, ActionKeys.EXPIRE);
170
171 journalArticleLocalService.expireArticle(
172 getUserId(), groupId, articleId, articleURL, serviceContext);
173 }
174
175 @Override
176 public JournalArticle getArticle(long id)
177 throws PortalException, SystemException {
178
179 JournalArticle article = journalArticleLocalService.getArticle(id);
180
181 JournalArticlePermission.check(
182 getPermissionChecker(), article, ActionKeys.VIEW);
183
184 return article;
185 }
186
187 @Override
188 public JournalArticle getArticle(long groupId, String articleId)
189 throws PortalException, SystemException {
190
191 JournalArticlePermission.check(
192 getPermissionChecker(), groupId, articleId, ActionKeys.VIEW);
193
194 return journalArticleLocalService.getArticle(groupId, articleId);
195 }
196
197 @Override
198 public JournalArticle getArticle(
199 long groupId, String articleId, double version)
200 throws PortalException, SystemException {
201
202 JournalArticlePermission.check(
203 getPermissionChecker(), groupId, articleId, version,
204 ActionKeys.VIEW);
205
206 return journalArticleLocalService.getArticle(
207 groupId, articleId, version);
208 }
209
210 @Override
211 public JournalArticle getArticle(
212 long groupId, String className, long classPK)
213 throws PortalException, SystemException {
214
215 JournalArticle article = journalArticleLocalService.getArticle(
216 groupId, className, classPK);
217
218 JournalArticlePermission.check(
219 getPermissionChecker(), groupId, article.getArticleId(),
220 article.getVersion(), ActionKeys.VIEW);
221
222 return article;
223 }
224
225 @Override
226 public JournalArticle getArticleByUrlTitle(long groupId, String urlTitle)
227 throws PortalException, SystemException {
228
229 JournalArticle article =
230 journalArticleLocalService.getArticleByUrlTitle(groupId, urlTitle);
231
232 JournalArticlePermission.check(
233 getPermissionChecker(), article, ActionKeys.VIEW);
234
235 return article;
236 }
237
238 @Override
239 public String getArticleContent(
240 long groupId, String articleId, double version, String languageId,
241 ThemeDisplay themeDisplay)
242 throws PortalException, SystemException {
243
244 JournalArticlePermission.check(
245 getPermissionChecker(), groupId, articleId, version,
246 ActionKeys.VIEW);
247
248 return journalArticleLocalService.getArticleContent(
249 groupId, articleId, version, null, languageId, themeDisplay);
250 }
251
252 @Override
253 public String getArticleContent(
254 long groupId, String articleId, String languageId,
255 ThemeDisplay themeDisplay)
256 throws PortalException, SystemException {
257
258 JournalArticlePermission.check(
259 getPermissionChecker(), groupId, articleId, ActionKeys.VIEW);
260
261 return journalArticleLocalService.getArticleContent(
262 groupId, articleId, null, languageId, themeDisplay);
263 }
264
265 @Override
266 public List<JournalArticle> getArticlesByArticleId(
267 long groupId, String articleId, int start, int end,
268 OrderByComparator obc)
269 throws SystemException {
270
271 return journalArticlePersistence.filterFindByG_A(
272 groupId, articleId, start, end, obc);
273 }
274
275 @Override
276 public List<JournalArticle> getArticlesByLayoutUuid(
277 long groupId, String layoutUuid)
278 throws SystemException {
279
280 return journalArticlePersistence.filterFindByG_L(groupId, layoutUuid);
281 }
282
283 @Override
284 public int getArticlesCountByArticleId(long groupId, String articleId)
285 throws SystemException {
286
287 return journalArticlePersistence.filterCountByG_A(groupId, articleId);
288 }
289
290 @Override
291 public JournalArticle getDisplayArticleByUrlTitle(
292 long groupId, String urlTitle)
293 throws PortalException, SystemException {
294
295 JournalArticle article =
296 journalArticleLocalService.getDisplayArticleByUrlTitle(
297 groupId, urlTitle);
298
299 JournalArticlePermission.check(
300 getPermissionChecker(), article, ActionKeys.VIEW);
301
302 return article;
303 }
304
305 @Override
306 public JournalArticle getLatestArticle(long resourcePrimKey)
307 throws PortalException, SystemException {
308
309 JournalArticlePermission.check(
310 getPermissionChecker(), resourcePrimKey, ActionKeys.VIEW);
311
312 return journalArticleLocalService.getLatestArticle(resourcePrimKey);
313 }
314
315 @Override
316 public JournalArticle getLatestArticle(
317 long groupId, String articleId, int status)
318 throws PortalException, SystemException {
319
320 JournalArticlePermission.check(
321 getPermissionChecker(), groupId, articleId, status,
322 ActionKeys.VIEW);
323
324 return journalArticleLocalService.getLatestArticle(
325 groupId, articleId, status);
326 }
327
328 @Override
329 public JournalArticle getLatestArticle(
330 long groupId, String className, long classPK)
331 throws PortalException, SystemException {
332
333 JournalArticle article = journalArticleLocalService.getLatestArticle(
334 groupId, className, classPK);
335
336 JournalArticlePermission.check(
337 getPermissionChecker(), groupId, article.getArticleId(),
338 article.getVersion(), ActionKeys.VIEW);
339
340 return article;
341 }
342
343 @Override
344 public void removeArticleLocale(long companyId, String languageId)
345 throws PortalException, SystemException {
346
347 for (JournalArticle article :
348 journalArticlePersistence.findByCompanyId(companyId)) {
349
350 removeArticleLocale(
351 article.getGroupId(), article.getArticleId(),
352 article.getVersion(), languageId);
353 }
354 }
355
356 @Override
357 public JournalArticle removeArticleLocale(
358 long groupId, String articleId, double version, String languageId)
359 throws PortalException, SystemException {
360
361 JournalArticlePermission.check(
362 getPermissionChecker(), groupId, articleId, version,
363 ActionKeys.UPDATE);
364
365 return journalArticleLocalService.removeArticleLocale(
366 groupId, articleId, version, languageId);
367 }
368
369 @Override
370 public List<JournalArticle> search(
371 long companyId, long groupId, long classNameId, String keywords,
372 Double version, String type, String structureId, String templateId,
373 Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
374 int start, int end, OrderByComparator obc)
375 throws SystemException {
376
377 return journalArticleFinder.filterFindByKeywords(
378 companyId, groupId, classNameId, keywords, version, type,
379 structureId, templateId, displayDateGT, displayDateLT, status,
380 reviewDate, start, end, obc);
381 }
382
383 @Override
384 public List<JournalArticle> search(
385 long companyId, long groupId, long classNameId, String articleId,
386 Double version, String title, String description, String content,
387 String type, String structureId, String templateId,
388 Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
389 boolean andOperator, int start, int end, OrderByComparator obc)
390 throws SystemException {
391
392 return journalArticleFinder.filterFindByC_G_C_A_V_T_D_C_T_S_T_D_S_R(
393 companyId, groupId, classNameId, articleId, version, title,
394 description, content, type, structureId, templateId, displayDateGT,
395 displayDateLT, status, reviewDate, andOperator, start, end, obc);
396 }
397
398 @Override
399 public List<JournalArticle> search(
400 long companyId, long groupId, long classNameId, String articleId,
401 Double version, String title, String description, String content,
402 String type, String[] structureIds, String[] templateIds,
403 Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
404 boolean andOperator, int start, int end, OrderByComparator obc)
405 throws SystemException {
406
407 return journalArticleFinder.filterFindByC_G_C_A_V_T_D_C_T_S_T_D_S_R(
408 companyId, groupId, classNameId, articleId, version, title,
409 description, content, type, structureIds, templateIds,
410 displayDateGT, displayDateLT, status, reviewDate, andOperator,
411 start, end, obc);
412 }
413
414 @Override
415 public int searchCount(
416 long companyId, long groupId, long classNameId, String keywords,
417 Double version, String type, String structureId, String templateId,
418 Date displayDateGT, Date displayDateLT, int status, Date reviewDate)
419 throws SystemException {
420
421 return journalArticleFinder.filterCountByKeywords(
422 companyId, groupId, classNameId, keywords, version, type,
423 structureId, templateId, displayDateGT, displayDateLT, status,
424 reviewDate);
425 }
426
427 @Override
428 public int searchCount(
429 long companyId, long groupId, long classNameId, String articleId,
430 Double version, String title, String description, String content,
431 String type, String structureId, String templateId,
432 Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
433 boolean andOperator)
434 throws SystemException {
435
436 return journalArticleFinder.filterCountByC_G_C_A_V_T_D_C_T_S_T_D_S_R(
437 companyId, groupId, classNameId, articleId, version, title,
438 description, content, type, structureId, templateId, displayDateGT,
439 displayDateLT, status, reviewDate, andOperator);
440 }
441
442 @Override
443 public int searchCount(
444 long companyId, long groupId, long classNameId, String articleId,
445 Double version, String title, String description, String content,
446 String type, String[] structureIds, String[] templateIds,
447 Date displayDateGT, Date displayDateLT, int status, Date reviewDate,
448 boolean andOperator)
449 throws SystemException {
450
451 return journalArticleFinder.filterCountByC_G_C_A_V_T_D_C_T_S_T_D_S_R(
452 companyId, groupId, classNameId, articleId, version, title,
453 description, content, type, structureIds, templateIds,
454 displayDateGT, displayDateLT, status, reviewDate, andOperator);
455 }
456
457 @Override
458 public void subscribe(long groupId)
459 throws PortalException, SystemException {
460
461 JournalPermission.check(
462 getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);
463
464 journalArticleLocalService.subscribe(getUserId(), groupId);
465 }
466
467 @Override
468 public void unsubscribe(long groupId)
469 throws PortalException, SystemException {
470
471 JournalPermission.check(
472 getPermissionChecker(), groupId, ActionKeys.SUBSCRIBE);
473
474 journalArticleLocalService.unsubscribe(getUserId(), groupId);
475 }
476
477 @Override
478 public JournalArticle updateArticle(
479 long userId, long groupId, String articleId, double version,
480 Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
481 String content, String layoutUuid, ServiceContext serviceContext)
482 throws PortalException, SystemException {
483
484 return journalArticleLocalService.updateArticle(
485 userId, groupId, articleId, version, titleMap, descriptionMap,
486 content, layoutUuid, serviceContext);
487 }
488
489 @Override
490 public JournalArticle updateArticle(
491 long groupId, String articleId, double version,
492 Map<Locale, String> titleMap, Map<Locale, String> descriptionMap,
493 String content, String type, String structureId, String templateId,
494 String layoutUuid, int displayDateMonth, int displayDateDay,
495 int displayDateYear, int displayDateHour, int displayDateMinute,
496 int expirationDateMonth, int expirationDateDay,
497 int expirationDateYear, int expirationDateHour,
498 int expirationDateMinute, boolean neverExpire, int reviewDateMonth,
499 int reviewDateDay, int reviewDateYear, int reviewDateHour,
500 int reviewDateMinute, boolean neverReview, boolean indexable,
501 boolean smallImage, String smallImageURL, File smallFile,
502 Map<String, byte[]> images, String articleURL,
503 ServiceContext serviceContext)
504 throws PortalException, SystemException {
505
506 JournalArticlePermission.check(
507 getPermissionChecker(), groupId, articleId, version,
508 ActionKeys.UPDATE);
509
510 return journalArticleLocalService.updateArticle(
511 getUserId(), groupId, articleId, version, titleMap, descriptionMap,
512 content, type, structureId, templateId, layoutUuid,
513 displayDateMonth, displayDateDay, displayDateYear, displayDateHour,
514 displayDateMinute, expirationDateMonth, expirationDateDay,
515 expirationDateYear, expirationDateHour, expirationDateMinute,
516 neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear,
517 reviewDateHour, reviewDateMinute, neverReview, indexable,
518 smallImage, smallImageURL, smallFile, images, articleURL,
519 serviceContext);
520 }
521
522 @Override
523 public JournalArticle updateArticle(
524 long groupId, String articleId, double version, String content,
525 ServiceContext serviceContext)
526 throws PortalException, SystemException {
527
528 JournalArticlePermission.check(
529 getPermissionChecker(), groupId, articleId, version,
530 ActionKeys.UPDATE);
531
532 return journalArticleLocalService.updateArticle(
533 getUserId(), groupId, articleId, version, content, serviceContext);
534 }
535
536
540 @Override
541 public JournalArticle updateArticleTranslation(
542 long groupId, String articleId, double version, Locale locale,
543 String title, String description, String content,
544 Map<String, byte[]> images)
545 throws PortalException, SystemException {
546
547 return updateArticleTranslation(
548 groupId, articleId, version, locale, title, description, content,
549 images, null);
550 }
551
552 @Override
553 public JournalArticle updateArticleTranslation(
554 long groupId, String articleId, double version, Locale locale,
555 String title, String description, String content,
556 Map<String, byte[]> images, ServiceContext serviceContext)
557 throws PortalException, SystemException {
558
559 JournalArticlePermission.check(
560 getPermissionChecker(), groupId, articleId, version,
561 ActionKeys.UPDATE);
562
563 return journalArticleLocalService.updateArticleTranslation(
564 groupId, articleId, version, locale, title, description, content,
565 images, serviceContext);
566 }
567
568 @Override
569 public JournalArticle updateContent(
570 long groupId, String articleId, double version, String content)
571 throws PortalException, SystemException {
572
573 JournalArticlePermission.check(
574 getPermissionChecker(), groupId, articleId, version,
575 ActionKeys.UPDATE);
576
577 return journalArticleLocalService.updateContent(
578 groupId, articleId, version, content);
579 }
580
581 @Override
582 public JournalArticle updateStatus(
583 long groupId, String articleId, double version, int status,
584 String articleURL, ServiceContext serviceContext)
585 throws PortalException, SystemException {
586
587 JournalArticlePermission.check(
588 getPermissionChecker(), groupId, articleId, version,
589 ActionKeys.UPDATE);
590
591 return journalArticleLocalService.updateStatus(
592 getUserId(), groupId, articleId, version, status, articleURL,
593 serviceContext);
594 }
595
596 }