1   /**
2    * Copyright (c) 2000-2008 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.messageboards.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.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.StringPool;
30  import com.liferay.portal.kernel.util.StringUtil;
31  import com.liferay.portal.model.Company;
32  import com.liferay.portal.security.auth.PrincipalException;
33  import com.liferay.portal.theme.ThemeDisplay;
34  import com.liferay.portal.util.PortalUtil;
35  import com.liferay.portal.util.PropsUtil;
36  import com.liferay.portlet.messageboards.model.MBCategory;
37  import com.liferay.portlet.messageboards.model.MBMessage;
38  import com.liferay.portlet.messageboards.model.MBMessageDisplay;
39  import com.liferay.portlet.messageboards.model.MBThread;
40  import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
41  import com.liferay.portlet.messageboards.service.base.MBMessageServiceBaseImpl;
42  import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
43  import com.liferay.portlet.messageboards.service.permission.MBDiscussionPermission;
44  import com.liferay.portlet.messageboards.service.permission.MBMessagePermission;
45  import com.liferay.portlet.messageboards.util.comparator.MessageCreateDateComparator;
46  import com.liferay.util.Html;
47  import com.liferay.util.RSSUtil;
48  
49  import com.sun.syndication.feed.synd.SyndContent;
50  import com.sun.syndication.feed.synd.SyndContentImpl;
51  import com.sun.syndication.feed.synd.SyndEntry;
52  import com.sun.syndication.feed.synd.SyndEntryImpl;
53  import com.sun.syndication.feed.synd.SyndFeed;
54  import com.sun.syndication.feed.synd.SyndFeedImpl;
55  import com.sun.syndication.io.FeedException;
56  
57  import java.io.IOException;
58  
59  import java.util.ArrayList;
60  import java.util.Iterator;
61  import java.util.List;
62  
63  import javax.portlet.PortletPreferences;
64  
65  /**
66   * <a href="MBMessageServiceImpl.java.html"><b><i>View Source</i></b></a>
67   *
68   * @author Brian Wing Shun Chan
69   *
70   */
71  public class MBMessageServiceImpl extends MBMessageServiceBaseImpl {
72  
73      public MBMessage addDiscussionMessage(
74              long groupId, String className, long classPK, long threadId,
75              long parentMessageId, String subject, String body,
76              ThemeDisplay themeDisplay)
77          throws PortalException, SystemException {
78  
79          MBDiscussionPermission.check(
80              getPermissionChecker(), groupId, className, classPK,
81              ActionKeys.ADD_DISCUSSION);
82  
83          return mbMessageLocalService.addDiscussionMessage(
84              getUserId(), groupId, className, classPK, threadId, parentMessageId,
85              subject, body, themeDisplay);
86      }
87  
88      public MBMessage addMessage(
89              long categoryId, String subject, String body, List files,
90              boolean anonymous, double priority, String[] tagsEntries,
91              boolean addCommunityPermissions, boolean addGuestPermissions)
92          throws PortalException, SystemException {
93  
94          MBCategoryPermission.check(
95              getPermissionChecker(), categoryId, ActionKeys.ADD_MESSAGE);
96  
97          if (!MBCategoryPermission.contains(
98                  getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
99  
100             files.clear();
101         }
102 
103         if (!MBCategoryPermission.contains(
104                 getPermissionChecker(), categoryId,
105                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
106 
107             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
108         }
109 
110         return mbMessageLocalService.addMessage(
111             getGuestOrUserId(), categoryId, subject, body, files, anonymous,
112             priority, tagsEntries, null, addCommunityPermissions,
113             addGuestPermissions, null);
114     }
115 
116     public MBMessage addMessage(
117             long categoryId, String subject, String body, List files,
118             boolean anonymous, double priority, String[] tagsEntries,
119             String[] communityPermissions, String[] guestPermissions)
120         throws PortalException, SystemException {
121 
122         MBCategoryPermission.check(
123             getPermissionChecker(), categoryId, ActionKeys.ADD_MESSAGE);
124 
125         if (!MBCategoryPermission.contains(
126                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
127 
128             files.clear();
129         }
130 
131         if (!MBCategoryPermission.contains(
132                 getPermissionChecker(), categoryId,
133                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
134 
135             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
136         }
137 
138         return mbMessageLocalService.addMessage(
139             getGuestOrUserId(), categoryId, subject, body, files, anonymous,
140             priority, tagsEntries, null, communityPermissions, guestPermissions,
141             null);
142     }
143 
144     public MBMessage addMessage(
145             long categoryId, String subject, String body, List files,
146             boolean anonymous, double priority, String[] tagsEntries,
147             PortletPreferences prefs, boolean addCommunityPermissions,
148             boolean addGuestPermissions, ThemeDisplay themeDisplay)
149         throws PortalException, SystemException {
150 
151         MBCategoryPermission.check(
152             getPermissionChecker(), categoryId, ActionKeys.ADD_MESSAGE);
153 
154         if (!MBCategoryPermission.contains(
155                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
156 
157             files.clear();
158         }
159 
160         if (!MBCategoryPermission.contains(
161                 getPermissionChecker(), categoryId,
162                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
163 
164             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
165         }
166 
167         return mbMessageLocalService.addMessage(
168             getGuestOrUserId(), categoryId, subject, body, files, anonymous,
169             priority, tagsEntries, prefs, addCommunityPermissions,
170             addGuestPermissions, themeDisplay);
171     }
172 
173     public MBMessage addMessage(
174             long categoryId, String subject, String body, List files,
175             boolean anonymous, double priority, String[] tagsEntries,
176             PortletPreferences prefs, String[] communityPermissions,
177             String[] guestPermissions, ThemeDisplay themeDisplay)
178         throws PortalException, SystemException {
179 
180         MBCategoryPermission.check(
181             getPermissionChecker(), categoryId, ActionKeys.ADD_MESSAGE);
182 
183         if (!MBCategoryPermission.contains(
184                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
185 
186             files.clear();
187         }
188 
189         if (!MBCategoryPermission.contains(
190                 getPermissionChecker(), categoryId,
191                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
192 
193             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
194         }
195 
196         return mbMessageLocalService.addMessage(
197             getGuestOrUserId(), categoryId, subject, body, files, anonymous,
198             priority, tagsEntries, prefs, communityPermissions,
199             guestPermissions, themeDisplay);
200     }
201 
202     public MBMessage addMessage(
203             long categoryId, long threadId, long parentMessageId,
204             String subject, String body, List files, boolean anonymous,
205             double priority, String[] tagsEntries,
206             boolean addCommunityPermissions, boolean addGuestPermissions)
207         throws PortalException, SystemException {
208 
209         checkReplyToPermission(categoryId, parentMessageId);
210 
211         if (!MBCategoryPermission.contains(
212                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
213 
214             files.clear();
215         }
216 
217         if (!MBCategoryPermission.contains(
218                 getPermissionChecker(), categoryId,
219                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
220 
221             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
222         }
223 
224         return mbMessageLocalService.addMessage(
225             getGuestOrUserId(), categoryId, threadId, parentMessageId, subject,
226             body, files, anonymous, priority, tagsEntries, null,
227             addCommunityPermissions, addGuestPermissions, null);
228     }
229 
230     public MBMessage addMessage(
231             long categoryId, long threadId, long parentMessageId,
232             String subject, String body, List files, boolean anonymous,
233             double priority, String[] tagsEntries,
234             String[] communityPermissions, String[] guestPermissions)
235         throws PortalException, SystemException {
236 
237         checkReplyToPermission(categoryId, parentMessageId);
238 
239         if (!MBCategoryPermission.contains(
240                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
241 
242             files.clear();
243         }
244 
245         if (!MBCategoryPermission.contains(
246                 getPermissionChecker(), categoryId,
247                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
248 
249             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
250         }
251 
252         return mbMessageLocalService.addMessage(
253             getGuestOrUserId(), categoryId, threadId, parentMessageId, subject,
254             body, files, anonymous, priority, tagsEntries, null,
255             communityPermissions, guestPermissions, null);
256     }
257 
258     public MBMessage addMessage(
259             long categoryId, long threadId, long parentMessageId,
260             String subject, String body, List files, boolean anonymous,
261             double priority, String[] tagsEntries, PortletPreferences prefs,
262             boolean addCommunityPermissions, boolean addGuestPermissions,
263             ThemeDisplay themeDisplay)
264         throws PortalException, SystemException {
265 
266         checkReplyToPermission(categoryId, parentMessageId);
267 
268         if (!MBCategoryPermission.contains(
269                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
270 
271             files.clear();
272         }
273 
274         if (!MBCategoryPermission.contains(
275                 getPermissionChecker(), categoryId,
276                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
277 
278             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
279         }
280 
281         return mbMessageLocalService.addMessage(
282             getGuestOrUserId(), categoryId, threadId, parentMessageId, subject,
283             body, files, anonymous, priority, tagsEntries, prefs,
284             addCommunityPermissions, addGuestPermissions, themeDisplay);
285     }
286 
287     public MBMessage addMessage(
288             long categoryId, long threadId, long parentMessageId,
289             String subject, String body, List files, boolean anonymous,
290             double priority, String[] tagsEntries, PortletPreferences prefs,
291             String[] communityPermissions, String[] guestPermissions,
292             ThemeDisplay themeDisplay)
293         throws PortalException, SystemException {
294 
295         checkReplyToPermission(categoryId, parentMessageId);
296 
297         if (!MBCategoryPermission.contains(
298                 getPermissionChecker(), categoryId, ActionKeys.ADD_FILE)) {
299 
300             files.clear();
301         }
302 
303         if (!MBCategoryPermission.contains(
304                 getPermissionChecker(), categoryId,
305                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
306 
307             priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
308         }
309 
310         return mbMessageLocalService.addMessage(
311             getGuestOrUserId(), categoryId, threadId, parentMessageId, subject,
312             body, files, anonymous, priority, tagsEntries, prefs,
313             communityPermissions, guestPermissions, themeDisplay);
314     }
315 
316     public void deleteDiscussionMessage(
317             long groupId, String className, long classPK, long messageId)
318         throws PortalException, SystemException {
319 
320         MBDiscussionPermission.check(
321             getPermissionChecker(), groupId, className, classPK,
322             ActionKeys.DELETE_DISCUSSION);
323 
324         mbMessageLocalService.deleteDiscussionMessage(messageId);
325     }
326 
327     public void deleteMessage(long messageId)
328         throws PortalException, SystemException {
329 
330         MBMessagePermission.check(
331             getPermissionChecker(), messageId, ActionKeys.DELETE);
332 
333         mbMessageLocalService.deleteMessage(messageId);
334     }
335 
336     public List getCategoryMessages(long categoryId, int begin, int end)
337         throws PortalException, SystemException {
338 
339         List messages = new ArrayList();
340 
341         Iterator itr = mbMessageLocalService.getCategoryMessages(
342             categoryId, begin, end).iterator();
343 
344         while (itr.hasNext()) {
345             MBMessage message = (MBMessage)itr.next();
346 
347             if (MBMessagePermission.contains(
348                     getPermissionChecker(), message, ActionKeys.VIEW)) {
349 
350                 messages.add(message);
351             }
352         }
353 
354         return messages;
355     }
356 
357     public int getCategoryMessagesCount(long categoryId)
358         throws PortalException, SystemException {
359 
360         return mbMessageLocalService.getCategoryMessagesCount(categoryId);
361     }
362 
363     public String getCategoryMessagesRSS(
364             long categoryId, int max, String type, double version,
365             String displayStyle, String feedURL, String entryURL)
366         throws PortalException, SystemException {
367 
368         MBCategory category = mbCategoryLocalService.getCategory(
369             categoryId);
370 
371         String name = category.getName();
372         String description = category.getDescription();
373 
374         List messages = new ArrayList();
375 
376         MessageCreateDateComparator comparator =
377             new MessageCreateDateComparator(false, false);
378 
379         Iterator itr = mbMessageLocalService.getCategoryMessages(
380             categoryId, 0, _MAX_END, comparator).iterator();
381 
382         while (itr.hasNext() && (messages.size() < max)) {
383             MBMessage message = (MBMessage)itr.next();
384 
385             if (MBMessagePermission.contains(
386                     getPermissionChecker(), message, ActionKeys.VIEW)) {
387 
388                 messages.add(message);
389             }
390         }
391 
392         return exportToRSS(
393             name, description, type, version, displayStyle, feedURL, entryURL,
394             messages);
395     }
396 
397     public String getCompanyMessagesRSS(
398             long companyId, int max, String type, double version,
399             String displayStyle, String feedURL, String entryURL)
400         throws PortalException, SystemException {
401 
402         Company company = companyPersistence.findByPrimaryKey(companyId);
403 
404         String name = company.getName();
405         String description = company.getName();
406 
407         List messages = new ArrayList();
408 
409         MessageCreateDateComparator comparator =
410             new MessageCreateDateComparator(false, false);
411 
412         Iterator itr = mbMessageLocalService.getCompanyMessages(
413             companyId, 0, _MAX_END, comparator).iterator();
414 
415         while (itr.hasNext() && (messages.size() < max)) {
416             MBMessage message = (MBMessage)itr.next();
417 
418             if (MBMessagePermission.contains(
419                     getPermissionChecker(), message, ActionKeys.VIEW)) {
420 
421                 messages.add(message);
422             }
423         }
424 
425         return exportToRSS(
426             name, description, type, version, displayStyle, feedURL, entryURL,
427             messages);
428     }
429 
430     public String getGroupMessagesRSS(
431             long groupId, int max, String type, double version,
432             String displayStyle, String feedURL, String entryURL)
433         throws PortalException, SystemException {
434 
435         String name = StringPool.BLANK;
436         String description = StringPool.BLANK;
437 
438         List messages = new ArrayList();
439 
440         MessageCreateDateComparator comparator =
441             new MessageCreateDateComparator(false, true);
442 
443         Iterator itr = mbMessageLocalService.getGroupMessages(
444             groupId, 0, _MAX_END, comparator).iterator();
445 
446         while (itr.hasNext() && (messages.size() < max)) {
447             MBMessage message = (MBMessage)itr.next();
448 
449             if (MBMessagePermission.contains(
450                     getPermissionChecker(), message, ActionKeys.VIEW)) {
451 
452                 messages.add(message);
453             }
454         }
455 
456         if (messages.size() > 0) {
457             MBMessage message = (MBMessage)messages.get(messages.size() - 1);
458 
459             name = message.getSubject();
460             description = message.getSubject();
461         }
462 
463         return exportToRSS(
464             name, description, type, version, displayStyle, feedURL, entryURL,
465             messages);
466     }
467 
468     public String getGroupMessagesRSS(
469             long groupId, long userId, int max, String type, double version,
470             String displayStyle, String feedURL, String entryURL)
471         throws PortalException, SystemException {
472 
473         String name = StringPool.BLANK;
474         String description = StringPool.BLANK;
475 
476         List messages = new ArrayList();
477 
478         MessageCreateDateComparator comparator =
479             new MessageCreateDateComparator(false, true);
480 
481         Iterator itr = mbMessageLocalService.getGroupMessages(
482             groupId, userId, 0, _MAX_END, comparator).iterator();
483 
484         while (itr.hasNext() && (messages.size() < max)) {
485             MBMessage message = (MBMessage)itr.next();
486 
487             if (MBMessagePermission.contains(
488                     getPermissionChecker(), message, ActionKeys.VIEW)) {
489 
490                 messages.add(message);
491             }
492         }
493 
494         if (messages.size() > 0) {
495             MBMessage message = (MBMessage)messages.get(messages.size() - 1);
496 
497             name = message.getSubject();
498             description = message.getSubject();
499         }
500 
501         return exportToRSS(
502             name, description, type, version, displayStyle, feedURL, entryURL,
503             messages);
504     }
505 
506     public MBMessage getMessage(long messageId)
507         throws PortalException, SystemException {
508 
509         MBMessagePermission.check(
510             getPermissionChecker(), messageId, ActionKeys.VIEW);
511 
512         return mbMessageLocalService.getMessage(messageId);
513     }
514 
515     public MBMessageDisplay getMessageDisplay(long messageId)
516         throws PortalException, SystemException {
517 
518         MBMessagePermission.check(
519             getPermissionChecker(), messageId, ActionKeys.VIEW);
520 
521         return mbMessageLocalService.getMessageDisplay(messageId);
522     }
523 
524     public String getThreadMessagesRSS(
525             long threadId, int max, String type, double version,
526             String displayStyle, String feedURL, String entryURL)
527         throws PortalException, SystemException {
528 
529         String name = StringPool.BLANK;
530         String description = StringPool.BLANK;
531 
532         List messages = new ArrayList();
533 
534         MessageCreateDateComparator comparator =
535             new MessageCreateDateComparator(false, true);
536 
537         Iterator itr = mbMessageLocalService.getThreadMessages(
538             threadId, comparator).iterator();
539 
540         while (itr.hasNext() && (messages.size() < max)) {
541             MBMessage message = (MBMessage)itr.next();
542 
543             if (MBMessagePermission.contains(
544                     getPermissionChecker(), message, ActionKeys.VIEW)) {
545 
546                 messages.add(message);
547             }
548         }
549 
550         if (messages.size() > 0) {
551             MBMessage message = (MBMessage)messages.get(messages.size() - 1);
552 
553             name = message.getSubject();
554             description = message.getSubject();
555         }
556 
557         return exportToRSS(
558             name, description, type, version, displayStyle, feedURL, entryURL,
559             messages);
560     }
561 
562     public void subscribeMessage(long messageId)
563         throws PortalException, SystemException {
564 
565         MBMessagePermission.check(
566             getPermissionChecker(), messageId, ActionKeys.SUBSCRIBE);
567 
568         mbMessageLocalService.subscribeMessage(getUserId(), messageId);
569     }
570 
571     public void unsubscribeMessage(long messageId)
572         throws PortalException, SystemException {
573 
574         MBMessagePermission.check(
575             getPermissionChecker(), messageId, ActionKeys.SUBSCRIBE);
576 
577         mbMessageLocalService.unsubscribeMessage(getUserId(), messageId);
578     }
579 
580     public MBMessage updateDiscussionMessage(
581             long groupId, String className, long classPK, long messageId,
582             String subject, String body)
583         throws PortalException, SystemException {
584 
585         MBDiscussionPermission.check(
586             getPermissionChecker(), groupId, className, classPK,
587             ActionKeys.UPDATE_DISCUSSION);
588 
589         return mbMessageLocalService.updateDiscussionMessage(
590             getUserId(), messageId, subject, body);
591     }
592 
593     public MBMessage updateMessage(
594             long messageId, String subject, String body, List files,
595             double priority, String[] tagsEntries)
596         throws PortalException, SystemException {
597 
598         MBMessage message = mbMessageLocalService.getMessage(messageId);
599 
600         MBMessagePermission.check(
601             getPermissionChecker(), messageId, ActionKeys.UPDATE);
602 
603         if (!MBCategoryPermission.contains(
604                 getPermissionChecker(), message.getCategoryId(),
605                 ActionKeys.ADD_FILE)) {
606 
607             files.clear();
608         }
609 
610         if (!MBCategoryPermission.contains(
611                 getPermissionChecker(), message.getCategoryId(),
612                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
613 
614             MBThread thread = mbThreadLocalService.getThread(
615                 message.getThreadId());
616 
617             priority = thread.getPriority();
618         }
619 
620         return mbMessageLocalService.updateMessage(
621             getUserId(), messageId, subject, body, files, priority, tagsEntries,
622             null, null);
623     }
624 
625     public MBMessage updateMessage(
626             long messageId, String subject, String body, List files,
627             double priority, String[] tagsEntries, PortletPreferences prefs,
628             ThemeDisplay themeDisplay)
629         throws PortalException, SystemException {
630 
631         MBMessage message = mbMessageLocalService.getMessage(messageId);
632 
633         MBMessagePermission.check(
634             getPermissionChecker(), messageId, ActionKeys.UPDATE);
635 
636         if (!MBCategoryPermission.contains(
637                 getPermissionChecker(), message.getCategoryId(),
638                 ActionKeys.ADD_FILE)) {
639 
640             files.clear();
641         }
642 
643         if (!MBCategoryPermission.contains(
644                 getPermissionChecker(), message.getCategoryId(),
645                 ActionKeys.UPDATE_THREAD_PRIORITY)) {
646 
647             MBThread thread = mbThreadLocalService.getThread(
648                 message.getThreadId());
649 
650             priority = thread.getPriority();
651         }
652 
653         return mbMessageLocalService.updateMessage(
654             getUserId(), messageId, subject, body, files, priority, tagsEntries,
655             prefs, themeDisplay);
656     }
657 
658     protected void checkReplyToPermission(long categoryId, long parentMessageId)
659         throws PortalException, SystemException {
660 
661         if (parentMessageId > 0) {
662             if (MBCategoryPermission.contains(
663                     getPermissionChecker(), categoryId,
664                     ActionKeys.ADD_MESSAGE)) {
665 
666                 return;
667             }
668 
669             MBMessage parentMessage = mbMessagePersistence.fetchByPrimaryKey(
670                 parentMessageId);
671 
672             if ((parentMessage == null) ||
673                 !MBCategoryPermission.contains(
674                     getPermissionChecker(), categoryId,
675                     ActionKeys.REPLY_TO_MESSAGE)) {
676 
677                 throw new PrincipalException();
678             }
679         }
680         else {
681             MBCategoryPermission.check(
682                 getPermissionChecker(), categoryId, ActionKeys.ADD_MESSAGE);
683         }
684     }
685 
686     protected String exportToRSS(
687             String name, String description, String type, double version,
688             String displayStyle, String feedURL, String entryURL,
689             List messages)
690         throws SystemException {
691 
692         SyndFeed syndFeed = new SyndFeedImpl();
693 
694         syndFeed.setFeedType(type + "_" + version);
695         syndFeed.setTitle(name);
696         syndFeed.setLink(feedURL);
697         syndFeed.setDescription(description);
698 
699         List entries = new ArrayList();
700 
701         syndFeed.setEntries(entries);
702 
703         Iterator itr = messages.iterator();
704 
705         while (itr.hasNext()) {
706             MBMessage message = (MBMessage)itr.next();
707 
708             String author = PortalUtil.getUserName(
709                 message.getUserId(), message.getUserName());
710 
711             String value = null;
712 
713             if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
714                 value = StringUtil.shorten(
715                     Html.stripHtml(message.getBody()), _RSS_ABSTRACT_LENGTH,
716                     StringPool.BLANK);
717             }
718             else {
719                 value = message.getBody();
720             }
721 
722             SyndEntry syndEntry = new SyndEntryImpl();
723 
724             if (!message.isAnonymous()) {
725                 syndEntry.setAuthor(author);
726             }
727 
728             syndEntry.setTitle(message.getSubject());
729             syndEntry.setLink(
730                 entryURL + "&messageId=" + message.getMessageId());
731             syndEntry.setPublishedDate(message.getCreateDate());
732 
733             SyndContent syndContent = new SyndContentImpl();
734 
735             syndContent.setType("html");
736             syndContent.setValue(value);
737 
738             syndEntry.setDescription(syndContent);
739 
740             entries.add(syndEntry);
741         }
742 
743         try {
744             return RSSUtil.export(syndFeed);
745         }
746         catch (FeedException fe) {
747             throw new SystemException(fe);
748         }
749         catch (IOException ioe) {
750             throw new SystemException(ioe);
751         }
752     }
753 
754     private static final int _MAX_END = 200;
755 
756     private static final int _RSS_ABSTRACT_LENGTH = GetterUtil.getInteger(
757         PropsUtil.get(PropsUtil.MESSAGE_BOARDS_RSS_ABSTRACT_LENGTH));
758 
759 }