001
014
015 package com.liferay.portlet.wiki.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.language.LanguageUtil;
020 import com.liferay.portal.kernel.repository.model.FileEntry;
021 import com.liferay.portal.kernel.util.CalendarFactoryUtil;
022 import com.liferay.portal.kernel.util.HtmlUtil;
023 import com.liferay.portal.kernel.util.HttpUtil;
024 import com.liferay.portal.kernel.util.ObjectValuePair;
025 import com.liferay.portal.kernel.util.OrderByComparator;
026 import com.liferay.portal.kernel.util.StringBundler;
027 import com.liferay.portal.kernel.util.StringPool;
028 import com.liferay.portal.kernel.util.StringUtil;
029 import com.liferay.portal.kernel.workflow.WorkflowConstants;
030 import com.liferay.portal.security.permission.ActionKeys;
031 import com.liferay.portal.service.ServiceContext;
032 import com.liferay.portal.util.PortalUtil;
033 import com.liferay.portal.util.PortletKeys;
034 import com.liferay.portal.util.PropsValues;
035 import com.liferay.portlet.wiki.NoSuchPageException;
036 import com.liferay.portlet.wiki.model.WikiNode;
037 import com.liferay.portlet.wiki.model.WikiPage;
038 import com.liferay.portlet.wiki.model.WikiPageConstants;
039 import com.liferay.portlet.wiki.service.base.WikiPageServiceBaseImpl;
040 import com.liferay.portlet.wiki.service.permission.WikiNodePermission;
041 import com.liferay.portlet.wiki.service.permission.WikiPagePermission;
042 import com.liferay.portlet.wiki.util.WikiUtil;
043 import com.liferay.portlet.wiki.util.comparator.PageCreateDateComparator;
044 import com.liferay.util.RSSUtil;
045
046 import com.sun.syndication.feed.synd.SyndContent;
047 import com.sun.syndication.feed.synd.SyndContentImpl;
048 import com.sun.syndication.feed.synd.SyndEntry;
049 import com.sun.syndication.feed.synd.SyndEntryImpl;
050 import com.sun.syndication.feed.synd.SyndFeed;
051 import com.sun.syndication.feed.synd.SyndFeedImpl;
052 import com.sun.syndication.feed.synd.SyndLink;
053 import com.sun.syndication.feed.synd.SyndLinkImpl;
054 import com.sun.syndication.io.FeedException;
055
056 import java.io.File;
057 import java.io.InputStream;
058
059 import java.util.ArrayList;
060 import java.util.Calendar;
061 import java.util.Date;
062 import java.util.List;
063 import java.util.Locale;
064
065
074 public class WikiPageServiceImpl extends WikiPageServiceBaseImpl {
075
076 @Override
077 public WikiPage addPage(
078 long nodeId, String title, String content, String summary,
079 boolean minorEdit, ServiceContext serviceContext)
080 throws PortalException, SystemException {
081
082 WikiNodePermission.check(
083 getPermissionChecker(), nodeId, ActionKeys.ADD_PAGE);
084
085 return wikiPageLocalService.addPage(
086 getUserId(), nodeId, title, content, summary, minorEdit,
087 serviceContext);
088 }
089
090 @Override
091 public WikiPage addPage(
092 long nodeId, String title, String content, String summary,
093 boolean minorEdit, String format, String parentTitle,
094 String redirectTitle, ServiceContext serviceContext)
095 throws PortalException, SystemException {
096
097 WikiNodePermission.check(
098 getPermissionChecker(), nodeId, ActionKeys.ADD_PAGE);
099
100 return wikiPageLocalService.addPage(
101 getUserId(), nodeId, title, WikiPageConstants.VERSION_DEFAULT,
102 content, summary, minorEdit, format, true, parentTitle,
103 redirectTitle, serviceContext);
104 }
105
106 @Override
107 public void addPageAttachment(
108 long nodeId, String title, String fileName, File file,
109 String mimeType)
110 throws PortalException, SystemException {
111
112 WikiNodePermission.check(
113 getPermissionChecker(), nodeId, ActionKeys.ADD_ATTACHMENT);
114
115 wikiPageLocalService.addPageAttachment(
116 getUserId(), nodeId, title, fileName, file, mimeType);
117 }
118
119 @Override
120 public void addPageAttachment(
121 long nodeId, String title, String fileName, InputStream inputStream,
122 String mimeType)
123 throws PortalException, SystemException {
124
125 WikiNodePermission.check(
126 getPermissionChecker(), nodeId, ActionKeys.ADD_ATTACHMENT);
127
128 wikiPageLocalService.addPageAttachment(
129 getUserId(), nodeId, title, fileName, inputStream, mimeType);
130 }
131
132 @Override
133 public void addPageAttachments(
134 long nodeId, String title,
135 List<ObjectValuePair<String, InputStream>> inputStreamOVPs)
136 throws PortalException, SystemException {
137
138 WikiNodePermission.check(
139 getPermissionChecker(), nodeId, ActionKeys.ADD_ATTACHMENT);
140
141 wikiPageLocalService.addPageAttachments(
142 getUserId(), nodeId, title, inputStreamOVPs);
143 }
144
145 @Override
146 public void addTempPageAttachment(
147 long nodeId, String fileName, String tempFolderName,
148 InputStream inputStream, String mimeType)
149 throws PortalException, SystemException {
150
151 WikiNode node = wikiNodeLocalService.getNode(nodeId);
152
153 WikiNodePermission.check(
154 getPermissionChecker(), node, ActionKeys.ADD_ATTACHMENT);
155
156 wikiPageLocalService.addTempPageAttachment(
157 node.getGroupId(), getUserId(), fileName, tempFolderName,
158 inputStream, mimeType);
159 }
160
161 @Override
162 public void changeParent(
163 long nodeId, String title, String newParentTitle,
164 ServiceContext serviceContext)
165 throws PortalException, SystemException {
166
167 WikiPagePermission.check(
168 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
169
170 WikiNodePermission.check(
171 getPermissionChecker(), nodeId, ActionKeys.ADD_PAGE);
172
173 wikiPageLocalService.changeParent(
174 getUserId(), nodeId, title, newParentTitle, serviceContext);
175 }
176
177 @Override
178 public void copyPageAttachments(
179 long templateNodeId, String templateTitle, long nodeId,
180 String title)
181 throws PortalException, SystemException {
182
183 WikiNodePermission.check(
184 getPermissionChecker(), nodeId, ActionKeys.ADD_ATTACHMENT);
185
186 wikiPageLocalService.copyPageAttachments(
187 getUserId(), templateNodeId, templateTitle, nodeId, title);
188 }
189
190 @Override
191 public void deletePage(long nodeId, String title)
192 throws PortalException, SystemException {
193
194 WikiPagePermission.check(
195 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
196
197 wikiPageLocalService.deletePage(nodeId, title);
198 }
199
200
204 @Override
205 public void deletePage(long nodeId, String title, double version)
206 throws PortalException, SystemException {
207
208 discardDraft(nodeId, title, version);
209 }
210
211 @Override
212 public void deletePageAttachment(long nodeId, String title, String fileName)
213 throws PortalException, SystemException {
214
215 WikiPagePermission.check(
216 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
217
218 wikiPageLocalService.deletePageAttachment(nodeId, title, fileName);
219 }
220
221 @Override
222 public void deletePageAttachments(long nodeId, String title)
223 throws PortalException, SystemException {
224
225 WikiPagePermission.check(
226 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
227
228 wikiPageLocalService.deletePageAttachments(nodeId, title);
229 }
230
231 @Override
232 public void deleteTempPageAttachment(
233 long nodeId, String fileName, String tempFolderName)
234 throws PortalException, SystemException {
235
236 WikiNode node = wikiNodeLocalService.getNode(nodeId);
237
238 WikiNodePermission.check(
239 getPermissionChecker(), node, ActionKeys.ADD_ATTACHMENT);
240
241 wikiPageLocalService.deleteTempPageAttachment(
242 node.getGroupId(), getUserId(), fileName, tempFolderName);
243 }
244
245 @Override
246 public void deleteTrashPageAttachments(long nodeId, String title)
247 throws PortalException, SystemException {
248
249 WikiPagePermission.check(
250 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
251
252 wikiPageLocalService.deleteTrashPageAttachments(nodeId, title);
253 }
254
255 @Override
256 public void discardDraft(long nodeId, String title, double version)
257 throws PortalException, SystemException {
258
259 WikiPagePermission.check(
260 getPermissionChecker(), nodeId, title, version, ActionKeys.DELETE);
261
262 wikiPageLocalService.discardDraft(nodeId, title, version);
263 }
264
265 @Override
266 public List<WikiPage> getChildren(
267 long groupId, long nodeId, boolean head, String parentTitle)
268 throws PortalException, SystemException {
269
270 WikiNodePermission.check(
271 getPermissionChecker(), nodeId, ActionKeys.VIEW);
272
273 return wikiPagePersistence.filterFindByG_N_H_P_S(
274 groupId, nodeId, head, parentTitle,
275 WorkflowConstants.STATUS_APPROVED);
276 }
277
278 @Override
279 public WikiPage getDraftPage(long nodeId, String title)
280 throws PortalException, SystemException {
281
282 WikiPagePermission.check(
283 getPermissionChecker(), nodeId, title, ActionKeys.VIEW);
284
285 return wikiPageLocalService.getDraftPage(nodeId, title);
286 }
287
288 @Override
289 public List<WikiPage> getNodePages(long nodeId, int max)
290 throws PortalException, SystemException {
291
292 List<WikiPage> pages = new ArrayList<WikiPage>();
293
294 int lastIntervalStart = 0;
295 boolean listNotExhausted = true;
296
297 while ((pages.size() < max) && listNotExhausted) {
298 List<WikiPage> pageList = wikiPageLocalService.getPages(
299 nodeId, true, lastIntervalStart, lastIntervalStart + max);
300
301 lastIntervalStart += max;
302 listNotExhausted = (pageList.size() == max);
303
304 for (WikiPage page : pageList) {
305 if (pages.size() >= max) {
306 break;
307 }
308
309 if (WikiPagePermission.contains(
310 getPermissionChecker(), page, ActionKeys.VIEW)) {
311
312 pages.add(page);
313 }
314 }
315 }
316
317 return pages;
318 }
319
320
324 @Override
325 public String getNodePagesRSS(
326 long nodeId, int max, String type, double version,
327 String displayStyle, String feedURL, String entryURL)
328 throws PortalException, SystemException {
329
330 return getNodePagesRSS(
331 nodeId, max, type, version, displayStyle, feedURL, entryURL, null);
332 }
333
334 @Override
335 public String getNodePagesRSS(
336 long nodeId, int max, String type, double version,
337 String displayStyle, String feedURL, String entryURL,
338 String attachmentURLPrefix)
339 throws PortalException, SystemException {
340
341 WikiNodePermission.check(
342 getPermissionChecker(), nodeId, ActionKeys.VIEW);
343
344 WikiNode node = wikiNodePersistence.findByPrimaryKey(nodeId);
345
346 List<WikiPage> pages = getNodePages(nodeId, max);
347
348 return exportToRSS(
349 node.getCompanyId(), node.getName(), node.getDescription(), type,
350 version, displayStyle, feedURL, entryURL, attachmentURLPrefix,
351 pages, false, null);
352 }
353
354 @Override
355 public List<WikiPage> getOrphans(long groupId, long nodeId)
356 throws PortalException, SystemException {
357
358 WikiNodePermission.check(
359 getPermissionChecker(), nodeId, ActionKeys.VIEW);
360
361 List<WikiPage> pages = wikiPagePersistence.filterFindByG_N_H_S(
362 groupId, nodeId, true, WorkflowConstants.STATUS_APPROVED);
363
364 return WikiUtil.filterOrphans(pages);
365 }
366
367 @Override
368 public WikiPage getPage(long groupId, long nodeId, String title)
369 throws PortalException, SystemException {
370
371 List<WikiPage> pages = wikiPagePersistence.filterFindByG_N_T_H(
372 groupId, nodeId, title, true, 0, 1);
373
374 if (!pages.isEmpty()) {
375 return pages.get(0);
376 }
377 else {
378 StringBundler sb = new StringBundler(5);
379
380 sb.append("{nodeId=");
381 sb.append(nodeId);
382 sb.append(", title=");
383 sb.append(title);
384 sb.append("}");
385
386 throw new NoSuchPageException(sb.toString());
387 }
388 }
389
390 @Override
391 public WikiPage getPage(long nodeId, String title)
392 throws PortalException, SystemException {
393
394 WikiPagePermission.check(
395 getPermissionChecker(), nodeId, title, ActionKeys.VIEW);
396
397 return wikiPageLocalService.getPage(nodeId, title);
398 }
399
400 @Override
401 public WikiPage getPage(long nodeId, String title, Boolean head)
402 throws PortalException, SystemException {
403
404 WikiPagePermission.check(
405 getPermissionChecker(), nodeId, title, ActionKeys.VIEW);
406
407 return wikiPageLocalService.getPage(nodeId, title, head);
408 }
409
410 @Override
411 public WikiPage getPage(long nodeId, String title, double version)
412 throws PortalException, SystemException {
413
414 WikiPagePermission.check(
415 getPermissionChecker(), nodeId, title, ActionKeys.VIEW);
416
417 return wikiPageLocalService.getPage(nodeId, title, version);
418 }
419
420 @Override
421 public List<WikiPage> getPages(
422 long groupId, long nodeId, boolean head, int status, int start,
423 int end, OrderByComparator obc)
424 throws PortalException, SystemException {
425
426 WikiNodePermission.check(
427 getPermissionChecker(), nodeId, ActionKeys.VIEW);
428
429 if (status == WorkflowConstants.STATUS_ANY) {
430 return wikiPagePersistence.filterFindByG_N_H(
431 groupId, nodeId, head, start, end, obc);
432 }
433 else {
434 return wikiPagePersistence.filterFindByG_N_H_S(
435 groupId, nodeId, head, status, start, end, obc);
436 }
437 }
438
439 @Override
440 public List<WikiPage> getPages(
441 long groupId, long userId, long nodeId, int status, int start,
442 int end)
443 throws PortalException, SystemException {
444
445 WikiNodePermission.check(
446 getPermissionChecker(), nodeId, ActionKeys.VIEW);
447
448 if (userId > 0) {
449 return wikiPagePersistence.filterFindByG_U_N_S(
450 groupId, userId, nodeId, status, start, end,
451 new PageCreateDateComparator(false));
452 }
453 else {
454 return wikiPagePersistence.filterFindByG_N_S(
455 groupId, nodeId, status, start, end,
456 new PageCreateDateComparator(false));
457 }
458 }
459
460 @Override
461 public int getPagesCount(long groupId, long nodeId, boolean head)
462 throws PortalException, SystemException {
463
464 WikiNodePermission.check(
465 getPermissionChecker(), nodeId, ActionKeys.VIEW);
466
467 return wikiPagePersistence.filterCountByG_N_H_S(
468 groupId, nodeId, head, WorkflowConstants.STATUS_APPROVED);
469 }
470
471 @Override
472 public int getPagesCount(long groupId, long userId, long nodeId, int status)
473 throws PortalException, SystemException {
474
475 WikiNodePermission.check(
476 getPermissionChecker(), nodeId, ActionKeys.VIEW);
477
478 if (userId > 0) {
479 return wikiPagePersistence.filterCountByG_U_N_S(
480 groupId, userId, nodeId, status);
481 }
482 else {
483 return wikiPagePersistence.filterCountByG_N_S(
484 groupId, nodeId, status);
485 }
486 }
487
488
493 @Override
494 public String getPagesRSS(
495 long companyId, long nodeId, String title, int max, String type,
496 double version, String displayStyle, String feedURL,
497 String entryURL, Locale locale)
498 throws PortalException, SystemException {
499
500 return getPagesRSS(
501 companyId, nodeId, title, max, type, version, displayStyle, feedURL,
502 entryURL, null, locale);
503 }
504
505 @Override
506 public String getPagesRSS(
507 long companyId, long nodeId, String title, int max, String type,
508 double version, String displayStyle, String feedURL,
509 String entryURL, String attachmentURLPrefix, Locale locale)
510 throws PortalException, SystemException {
511
512 WikiPagePermission.check(
513 getPermissionChecker(), nodeId, title, ActionKeys.VIEW);
514
515 List<WikiPage> pages = wikiPageLocalService.getPages(
516 nodeId, title, 0, max, new PageCreateDateComparator(true));
517
518 return exportToRSS(
519 companyId, title, title, type, version, displayStyle, feedURL,
520 entryURL, attachmentURLPrefix, pages, true, locale);
521 }
522
523 @Override
524 public List<WikiPage> getRecentChanges(
525 long groupId, long nodeId, int start, int end)
526 throws PortalException, SystemException {
527
528 WikiNodePermission.check(
529 getPermissionChecker(), nodeId, ActionKeys.VIEW);
530
531 Calendar calendar = CalendarFactoryUtil.getCalendar();
532
533 calendar.add(Calendar.WEEK_OF_YEAR, -1);
534
535 return wikiPageFinder.filterFindByCreateDate(
536 groupId, nodeId, calendar.getTime(), false, start, end);
537 }
538
539 @Override
540 public int getRecentChangesCount(long groupId, long nodeId)
541 throws PortalException, SystemException {
542
543 WikiNodePermission.check(
544 getPermissionChecker(), nodeId, ActionKeys.VIEW);
545
546 Calendar calendar = CalendarFactoryUtil.getCalendar();
547
548 calendar.add(Calendar.WEEK_OF_YEAR, -1);
549
550 return wikiPageFinder.filterCountByCreateDate(
551 groupId, nodeId, calendar.getTime(), false);
552 }
553
554 @Override
555 public String[] getTempPageAttachmentNames(
556 long nodeId, String tempFolderName)
557 throws PortalException, SystemException {
558
559 WikiNode node = wikiNodeLocalService.getNode(nodeId);
560
561 WikiNodePermission.check(
562 getPermissionChecker(), node, ActionKeys.ADD_ATTACHMENT);
563
564 return wikiPageLocalService.getTempPageAttachmentNames(
565 node.getGroupId(), getUserId(), tempFolderName);
566 }
567
568 @Override
569 public void movePage(
570 long nodeId, String title, String newTitle,
571 ServiceContext serviceContext)
572 throws PortalException, SystemException {
573
574 WikiPagePermission.check(
575 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
576
577 WikiNodePermission.check(
578 getPermissionChecker(), nodeId, ActionKeys.ADD_PAGE);
579
580 wikiPageLocalService.movePage(
581 getUserId(), nodeId, title, newTitle, serviceContext);
582 }
583
584 @Override
585 public FileEntry movePageAttachmentToTrash(
586 long nodeId, String title, String fileName)
587 throws PortalException, SystemException {
588
589 WikiPagePermission.check(
590 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
591
592 return wikiPageLocalService.movePageAttachmentToTrash(
593 getUserId(), nodeId, title, fileName);
594 }
595
596 @Override
597 public WikiPage movePageToTrash(long nodeId, String title)
598 throws PortalException, SystemException {
599
600 WikiPagePermission.check(
601 getPermissionChecker(), nodeId, title, ActionKeys.DELETE);
602
603 return wikiPageLocalService.movePageToTrash(getUserId(), nodeId, title);
604 }
605
606 @Override
607 public WikiPage movePageToTrash(long nodeId, String title, double version)
608 throws PortalException, SystemException {
609
610 WikiPagePermission.check(
611 getPermissionChecker(), nodeId, title, version, ActionKeys.DELETE);
612
613 return wikiPageLocalService.movePageToTrash(
614 getUserId(), nodeId, title, version);
615 }
616
617 @Override
618 public void restorePageAttachmentFromTrash(
619 long nodeId, String title, String fileName)
620 throws PortalException, SystemException {
621
622 WikiNodePermission.check(
623 getPermissionChecker(), nodeId, ActionKeys.ADD_ATTACHMENT);
624
625 wikiPageLocalService.restorePageAttachmentFromTrash(
626 getUserId(), nodeId, title, fileName);
627 }
628
629 @Override
630 public void restorePageFromTrash(long resourcePrimKey)
631 throws PortalException, SystemException {
632
633 WikiPage page = wikiPageLocalService.getPage(resourcePrimKey);
634
635 WikiPagePermission.check(
636 getPermissionChecker(), page, ActionKeys.DELETE);
637
638 wikiPageLocalService.restorePageFromTrash(getUserId(), page);
639 }
640
641 @Override
642 public WikiPage revertPage(
643 long nodeId, String title, double version,
644 ServiceContext serviceContext)
645 throws PortalException, SystemException {
646
647 WikiPagePermission.check(
648 getPermissionChecker(), nodeId, title, ActionKeys.UPDATE);
649
650 return wikiPageLocalService.revertPage(
651 getUserId(), nodeId, title, version, serviceContext);
652 }
653
654 @Override
655 public void subscribePage(long nodeId, String title)
656 throws PortalException, SystemException {
657
658 WikiPagePermission.check(
659 getPermissionChecker(), nodeId, title, ActionKeys.SUBSCRIBE);
660
661 wikiPageLocalService.subscribePage(getUserId(), nodeId, title);
662 }
663
664 @Override
665 public void unsubscribePage(long nodeId, String title)
666 throws PortalException, SystemException {
667
668 WikiPagePermission.check(
669 getPermissionChecker(), nodeId, title, ActionKeys.SUBSCRIBE);
670
671 wikiPageLocalService.unsubscribePage(getUserId(), nodeId, title);
672 }
673
674 @Override
675 public WikiPage updatePage(
676 long nodeId, String title, double version, String content,
677 String summary, boolean minorEdit, String format,
678 String parentTitle, String redirectTitle,
679 ServiceContext serviceContext)
680 throws PortalException, SystemException {
681
682 WikiPagePermission.check(
683 getPermissionChecker(), nodeId, title, ActionKeys.UPDATE);
684
685 return wikiPageLocalService.updatePage(
686 getUserId(), nodeId, title, version, content, summary, minorEdit,
687 format, parentTitle, redirectTitle, serviceContext);
688 }
689
690 protected String exportToRSS(
691 long companyId, String name, String description, String type,
692 double version, String displayStyle, String feedURL,
693 String entryURL, String attachmentURLPrefix, List<WikiPage> pages,
694 boolean diff, Locale locale)
695 throws PortalException, SystemException {
696
697 SyndFeed syndFeed = new SyndFeedImpl();
698
699 syndFeed.setDescription(description);
700
701 List<SyndEntry> syndEntries = new ArrayList<SyndEntry>();
702
703 syndFeed.setEntries(syndEntries);
704
705 WikiPage latestPage = null;
706
707 StringBundler sb = new StringBundler(6);
708
709 for (WikiPage page : pages) {
710 SyndEntry syndEntry = new SyndEntryImpl();
711
712 String author = PortalUtil.getUserName(page);
713
714 syndEntry.setAuthor(author);
715
716 SyndContent syndContent = new SyndContentImpl();
717
718 syndContent.setType(RSSUtil.ENTRY_TYPE_DEFAULT);
719
720 sb.setIndex(0);
721
722 sb.append(entryURL);
723
724 if (entryURL.endsWith(StringPool.SLASH)) {
725 sb.append(HttpUtil.encodeURL(page.getTitle()));
726 }
727
728 if (diff) {
729 if ((latestPage != null) || (pages.size() == 1)) {
730 sb.append(StringPool.QUESTION);
731 sb.append(PortalUtil.getPortletNamespace(PortletKeys.WIKI));
732 sb.append("version=");
733 sb.append(page.getVersion());
734
735 String value = null;
736
737 if (latestPage == null) {
738 value = WikiUtil.convert(
739 page, null, null, attachmentURLPrefix);
740 }
741 else {
742 try {
743 value = WikiUtil.diffHtml(
744 latestPage, page, null, null,
745 attachmentURLPrefix);
746 }
747 catch (PortalException pe) {
748 throw pe;
749 }
750 catch (SystemException se) {
751 throw se;
752 }
753 catch (Exception e) {
754 throw new SystemException(e);
755 }
756 }
757
758 syndContent.setValue(value);
759
760 syndEntry.setDescription(syndContent);
761
762 syndEntries.add(syndEntry);
763 }
764 }
765 else {
766 String value = null;
767
768 if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
769 value = StringUtil.shorten(
770 HtmlUtil.extractText(page.getContent()),
771 PropsValues.WIKI_RSS_ABSTRACT_LENGTH, StringPool.BLANK);
772 }
773 else if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_TITLE)) {
774 value = StringPool.BLANK;
775 }
776 else {
777 value = WikiUtil.convert(
778 page, null, null, attachmentURLPrefix);
779 }
780
781 syndContent.setValue(value);
782
783 syndEntry.setDescription(syndContent);
784
785 syndEntries.add(syndEntry);
786 }
787
788 syndEntry.setLink(sb.toString());
789 syndEntry.setPublishedDate(page.getCreateDate());
790
791 String title =
792 page.getTitle() + StringPool.SPACE + page.getVersion();
793
794 if (page.isMinorEdit()) {
795 title +=
796 StringPool.SPACE + StringPool.OPEN_PARENTHESIS +
797 LanguageUtil.get(locale, "minor-edit") +
798 StringPool.CLOSE_PARENTHESIS;
799 }
800
801 syndEntry.setTitle(title);
802
803 syndEntry.setUpdatedDate(page.getModifiedDate());
804 syndEntry.setUri(sb.toString());
805
806 latestPage = page;
807 }
808
809 syndFeed.setFeedType(RSSUtil.getFeedType(type, version));
810
811 List<SyndLink> syndLinks = new ArrayList<SyndLink>();
812
813 syndFeed.setLinks(syndLinks);
814
815 SyndLink syndLinkSelf = new SyndLinkImpl();
816
817 syndLinks.add(syndLinkSelf);
818
819 syndLinkSelf.setHref(feedURL);
820 syndLinkSelf.setRel("self");
821
822 syndFeed.setPublishedDate(new Date());
823 syndFeed.setTitle(name);
824 syndFeed.setUri(feedURL);
825
826 try {
827 return RSSUtil.export(syndFeed);
828 }
829 catch (FeedException fe) {
830 throw new SystemException(fe);
831 }
832 }
833
834 }