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