Source Code Cross Referenced for MBMessageServiceImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portlet » messageboards » service » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portlet.messageboards.service.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portlet.messageboards.service.impl;
022:
023:        import com.liferay.portal.PortalException;
024:        import com.liferay.portal.SystemException;
025:        import com.liferay.portal.kernel.security.permission.ActionKeys;
026:        import com.liferay.portal.kernel.util.GetterUtil;
027:        import com.liferay.portal.kernel.util.StringPool;
028:        import com.liferay.portal.kernel.util.StringUtil;
029:        import com.liferay.portal.model.Company;
030:        import com.liferay.portal.security.auth.PrincipalException;
031:        import com.liferay.portal.theme.ThemeDisplay;
032:        import com.liferay.portal.util.PortalUtil;
033:        import com.liferay.portal.util.PropsUtil;
034:        import com.liferay.portlet.messageboards.model.MBCategory;
035:        import com.liferay.portlet.messageboards.model.MBMessage;
036:        import com.liferay.portlet.messageboards.model.MBMessageDisplay;
037:        import com.liferay.portlet.messageboards.model.MBThread;
038:        import com.liferay.portlet.messageboards.model.impl.MBThreadImpl;
039:        import com.liferay.portlet.messageboards.service.base.MBMessageServiceBaseImpl;
040:        import com.liferay.portlet.messageboards.service.permission.MBCategoryPermission;
041:        import com.liferay.portlet.messageboards.service.permission.MBDiscussionPermission;
042:        import com.liferay.portlet.messageboards.service.permission.MBMessagePermission;
043:        import com.liferay.portlet.messageboards.util.comparator.MessageCreateDateComparator;
044:        import com.liferay.util.Html;
045:        import com.liferay.util.RSSUtil;
046:
047:        import com.sun.syndication.feed.synd.SyndContent;
048:        import com.sun.syndication.feed.synd.SyndContentImpl;
049:        import com.sun.syndication.feed.synd.SyndEntry;
050:        import com.sun.syndication.feed.synd.SyndEntryImpl;
051:        import com.sun.syndication.feed.synd.SyndFeed;
052:        import com.sun.syndication.feed.synd.SyndFeedImpl;
053:        import com.sun.syndication.io.FeedException;
054:
055:        import java.io.IOException;
056:
057:        import java.util.ArrayList;
058:        import java.util.Iterator;
059:        import java.util.List;
060:
061:        import javax.portlet.PortletPreferences;
062:
063:        /**
064:         * <a href="MBMessageServiceImpl.java.html"><b><i>View Source</i></b></a>
065:         *
066:         * @author Brian Wing Shun Chan
067:         *
068:         */
069:        public class MBMessageServiceImpl extends MBMessageServiceBaseImpl {
070:
071:            public MBMessage addDiscussionMessage(long groupId,
072:                    String className, long classPK, long threadId,
073:                    long parentMessageId, String subject, String body,
074:                    ThemeDisplay themeDisplay) throws PortalException,
075:                    SystemException {
076:
077:                MBDiscussionPermission.check(getPermissionChecker(), groupId,
078:                        className, classPK, ActionKeys.ADD_DISCUSSION);
079:
080:                return mbMessageLocalService.addDiscussionMessage(getUserId(),
081:                        groupId, className, classPK, threadId, parentMessageId,
082:                        subject, body, themeDisplay);
083:            }
084:
085:            public MBMessage addMessage(long categoryId, String subject,
086:                    String body, List files, boolean anonymous,
087:                    double priority, String[] tagsEntries,
088:                    boolean addCommunityPermissions, boolean addGuestPermissions)
089:                    throws PortalException, SystemException {
090:
091:                MBCategoryPermission.check(getPermissionChecker(), categoryId,
092:                        ActionKeys.ADD_MESSAGE);
093:
094:                if (!MBCategoryPermission.contains(getPermissionChecker(),
095:                        categoryId, ActionKeys.ADD_FILE)) {
096:
097:                    files.clear();
098:                }
099:
100:                if (!MBCategoryPermission.contains(getPermissionChecker(),
101:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
102:
103:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
104:                }
105:
106:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
107:                        categoryId, subject, body, files, anonymous, priority,
108:                        tagsEntries, null, addCommunityPermissions,
109:                        addGuestPermissions, null);
110:            }
111:
112:            public MBMessage addMessage(long categoryId, String subject,
113:                    String body, List files, boolean anonymous,
114:                    double priority, String[] tagsEntries,
115:                    String[] communityPermissions, String[] guestPermissions)
116:                    throws PortalException, SystemException {
117:
118:                MBCategoryPermission.check(getPermissionChecker(), categoryId,
119:                        ActionKeys.ADD_MESSAGE);
120:
121:                if (!MBCategoryPermission.contains(getPermissionChecker(),
122:                        categoryId, ActionKeys.ADD_FILE)) {
123:
124:                    files.clear();
125:                }
126:
127:                if (!MBCategoryPermission.contains(getPermissionChecker(),
128:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
129:
130:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
131:                }
132:
133:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
134:                        categoryId, subject, body, files, anonymous, priority,
135:                        tagsEntries, null, communityPermissions,
136:                        guestPermissions, null);
137:            }
138:
139:            public MBMessage addMessage(long categoryId, String subject,
140:                    String body, List files, boolean anonymous,
141:                    double priority, String[] tagsEntries,
142:                    PortletPreferences prefs, boolean addCommunityPermissions,
143:                    boolean addGuestPermissions, ThemeDisplay themeDisplay)
144:                    throws PortalException, SystemException {
145:
146:                MBCategoryPermission.check(getPermissionChecker(), categoryId,
147:                        ActionKeys.ADD_MESSAGE);
148:
149:                if (!MBCategoryPermission.contains(getPermissionChecker(),
150:                        categoryId, ActionKeys.ADD_FILE)) {
151:
152:                    files.clear();
153:                }
154:
155:                if (!MBCategoryPermission.contains(getPermissionChecker(),
156:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
157:
158:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
159:                }
160:
161:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
162:                        categoryId, subject, body, files, anonymous, priority,
163:                        tagsEntries, prefs, addCommunityPermissions,
164:                        addGuestPermissions, themeDisplay);
165:            }
166:
167:            public MBMessage addMessage(long categoryId, String subject,
168:                    String body, List files, boolean anonymous,
169:                    double priority, String[] tagsEntries,
170:                    PortletPreferences prefs, String[] communityPermissions,
171:                    String[] guestPermissions, ThemeDisplay themeDisplay)
172:                    throws PortalException, SystemException {
173:
174:                MBCategoryPermission.check(getPermissionChecker(), categoryId,
175:                        ActionKeys.ADD_MESSAGE);
176:
177:                if (!MBCategoryPermission.contains(getPermissionChecker(),
178:                        categoryId, ActionKeys.ADD_FILE)) {
179:
180:                    files.clear();
181:                }
182:
183:                if (!MBCategoryPermission.contains(getPermissionChecker(),
184:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
185:
186:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
187:                }
188:
189:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
190:                        categoryId, subject, body, files, anonymous, priority,
191:                        tagsEntries, prefs, communityPermissions,
192:                        guestPermissions, themeDisplay);
193:            }
194:
195:            public MBMessage addMessage(long categoryId, long threadId,
196:                    long parentMessageId, String subject, String body,
197:                    List files, boolean anonymous, double priority,
198:                    String[] tagsEntries, boolean addCommunityPermissions,
199:                    boolean addGuestPermissions) throws PortalException,
200:                    SystemException {
201:
202:                checkReplyToPermission(categoryId, parentMessageId);
203:
204:                if (!MBCategoryPermission.contains(getPermissionChecker(),
205:                        categoryId, ActionKeys.ADD_FILE)) {
206:
207:                    files.clear();
208:                }
209:
210:                if (!MBCategoryPermission.contains(getPermissionChecker(),
211:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
212:
213:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
214:                }
215:
216:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
217:                        categoryId, threadId, parentMessageId, subject, body,
218:                        files, anonymous, priority, tagsEntries, null,
219:                        addCommunityPermissions, addGuestPermissions, null);
220:            }
221:
222:            public MBMessage addMessage(long categoryId, long threadId,
223:                    long parentMessageId, String subject, String body,
224:                    List files, boolean anonymous, double priority,
225:                    String[] tagsEntries, String[] communityPermissions,
226:                    String[] guestPermissions) throws PortalException,
227:                    SystemException {
228:
229:                checkReplyToPermission(categoryId, parentMessageId);
230:
231:                if (!MBCategoryPermission.contains(getPermissionChecker(),
232:                        categoryId, ActionKeys.ADD_FILE)) {
233:
234:                    files.clear();
235:                }
236:
237:                if (!MBCategoryPermission.contains(getPermissionChecker(),
238:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
239:
240:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
241:                }
242:
243:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
244:                        categoryId, threadId, parentMessageId, subject, body,
245:                        files, anonymous, priority, tagsEntries, null,
246:                        communityPermissions, guestPermissions, null);
247:            }
248:
249:            public MBMessage addMessage(long categoryId, long threadId,
250:                    long parentMessageId, String subject, String body,
251:                    List files, boolean anonymous, double priority,
252:                    String[] tagsEntries, PortletPreferences prefs,
253:                    boolean addCommunityPermissions,
254:                    boolean addGuestPermissions, ThemeDisplay themeDisplay)
255:                    throws PortalException, SystemException {
256:
257:                checkReplyToPermission(categoryId, parentMessageId);
258:
259:                if (!MBCategoryPermission.contains(getPermissionChecker(),
260:                        categoryId, ActionKeys.ADD_FILE)) {
261:
262:                    files.clear();
263:                }
264:
265:                if (!MBCategoryPermission.contains(getPermissionChecker(),
266:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
267:
268:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
269:                }
270:
271:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
272:                        categoryId, threadId, parentMessageId, subject, body,
273:                        files, anonymous, priority, tagsEntries, prefs,
274:                        addCommunityPermissions, addGuestPermissions,
275:                        themeDisplay);
276:            }
277:
278:            public MBMessage addMessage(long categoryId, long threadId,
279:                    long parentMessageId, String subject, String body,
280:                    List files, boolean anonymous, double priority,
281:                    String[] tagsEntries, PortletPreferences prefs,
282:                    String[] communityPermissions, String[] guestPermissions,
283:                    ThemeDisplay themeDisplay) throws PortalException,
284:                    SystemException {
285:
286:                checkReplyToPermission(categoryId, parentMessageId);
287:
288:                if (!MBCategoryPermission.contains(getPermissionChecker(),
289:                        categoryId, ActionKeys.ADD_FILE)) {
290:
291:                    files.clear();
292:                }
293:
294:                if (!MBCategoryPermission.contains(getPermissionChecker(),
295:                        categoryId, ActionKeys.UPDATE_THREAD_PRIORITY)) {
296:
297:                    priority = MBThreadImpl.PRIORITY_NOT_GIVEN;
298:                }
299:
300:                return mbMessageLocalService.addMessage(getGuestOrUserId(),
301:                        categoryId, threadId, parentMessageId, subject, body,
302:                        files, anonymous, priority, tagsEntries, prefs,
303:                        communityPermissions, guestPermissions, themeDisplay);
304:            }
305:
306:            public void deleteDiscussionMessage(long groupId, String className,
307:                    long classPK, long messageId) throws PortalException,
308:                    SystemException {
309:
310:                MBDiscussionPermission.check(getPermissionChecker(), groupId,
311:                        className, classPK, ActionKeys.DELETE_DISCUSSION);
312:
313:                mbMessageLocalService.deleteDiscussionMessage(messageId);
314:            }
315:
316:            public void deleteMessage(long messageId) throws PortalException,
317:                    SystemException {
318:
319:                MBMessagePermission.check(getPermissionChecker(), messageId,
320:                        ActionKeys.DELETE);
321:
322:                mbMessageLocalService.deleteMessage(messageId);
323:            }
324:
325:            public List getCategoryMessages(long categoryId, int begin, int end)
326:                    throws PortalException, SystemException {
327:
328:                List messages = new ArrayList();
329:
330:                Iterator itr = mbMessageLocalService.getCategoryMessages(
331:                        categoryId, begin, end).iterator();
332:
333:                while (itr.hasNext()) {
334:                    MBMessage message = (MBMessage) itr.next();
335:
336:                    if (MBMessagePermission.contains(getPermissionChecker(),
337:                            message, ActionKeys.VIEW)) {
338:
339:                        messages.add(message);
340:                    }
341:                }
342:
343:                return messages;
344:            }
345:
346:            public int getCategoryMessagesCount(long categoryId)
347:                    throws PortalException, SystemException {
348:
349:                return mbMessageLocalService
350:                        .getCategoryMessagesCount(categoryId);
351:            }
352:
353:            public String getCategoryMessagesRSS(long categoryId, int max,
354:                    String type, double version, String displayStyle,
355:                    String feedURL, String entryURL) throws PortalException,
356:                    SystemException {
357:
358:                MBCategory category = mbCategoryLocalService
359:                        .getCategory(categoryId);
360:
361:                String name = category.getName();
362:                String description = category.getDescription();
363:
364:                List messages = new ArrayList();
365:
366:                MessageCreateDateComparator comparator = new MessageCreateDateComparator(
367:                        false, false);
368:
369:                Iterator itr = mbMessageLocalService.getCategoryMessages(
370:                        categoryId, 0, _MAX_END, comparator).iterator();
371:
372:                while (itr.hasNext() && (messages.size() < max)) {
373:                    MBMessage message = (MBMessage) itr.next();
374:
375:                    if (MBMessagePermission.contains(getPermissionChecker(),
376:                            message, ActionKeys.VIEW)) {
377:
378:                        messages.add(message);
379:                    }
380:                }
381:
382:                return exportToRSS(name, description, type, version,
383:                        displayStyle, feedURL, entryURL, messages);
384:            }
385:
386:            public String getCompanyMessagesRSS(long companyId, int max,
387:                    String type, double version, String displayStyle,
388:                    String feedURL, String entryURL) throws PortalException,
389:                    SystemException {
390:
391:                Company company = companyPersistence
392:                        .findByPrimaryKey(companyId);
393:
394:                String name = company.getName();
395:                String description = company.getName();
396:
397:                List messages = new ArrayList();
398:
399:                MessageCreateDateComparator comparator = new MessageCreateDateComparator(
400:                        false, false);
401:
402:                Iterator itr = mbMessageLocalService.getCompanyMessages(
403:                        companyId, 0, _MAX_END, comparator).iterator();
404:
405:                while (itr.hasNext() && (messages.size() < max)) {
406:                    MBMessage message = (MBMessage) itr.next();
407:
408:                    if (MBMessagePermission.contains(getPermissionChecker(),
409:                            message, ActionKeys.VIEW)) {
410:
411:                        messages.add(message);
412:                    }
413:                }
414:
415:                return exportToRSS(name, description, type, version,
416:                        displayStyle, feedURL, entryURL, messages);
417:            }
418:
419:            public String getGroupMessagesRSS(long groupId, int max,
420:                    String type, double version, String displayStyle,
421:                    String feedURL, String entryURL) throws PortalException,
422:                    SystemException {
423:
424:                String name = StringPool.BLANK;
425:                String description = StringPool.BLANK;
426:
427:                List messages = new ArrayList();
428:
429:                MessageCreateDateComparator comparator = new MessageCreateDateComparator(
430:                        false, true);
431:
432:                Iterator itr = mbMessageLocalService.getGroupMessages(groupId,
433:                        0, _MAX_END, comparator).iterator();
434:
435:                while (itr.hasNext() && (messages.size() < max)) {
436:                    MBMessage message = (MBMessage) itr.next();
437:
438:                    if (MBMessagePermission.contains(getPermissionChecker(),
439:                            message, ActionKeys.VIEW)) {
440:
441:                        messages.add(message);
442:                    }
443:                }
444:
445:                if (messages.size() > 0) {
446:                    MBMessage message = (MBMessage) messages.get(messages
447:                            .size() - 1);
448:
449:                    name = message.getSubject();
450:                    description = message.getSubject();
451:                }
452:
453:                return exportToRSS(name, description, type, version,
454:                        displayStyle, feedURL, entryURL, messages);
455:            }
456:
457:            public String getGroupMessagesRSS(long groupId, long userId,
458:                    int max, String type, double version, String displayStyle,
459:                    String feedURL, String entryURL) throws PortalException,
460:                    SystemException {
461:
462:                String name = StringPool.BLANK;
463:                String description = StringPool.BLANK;
464:
465:                List messages = new ArrayList();
466:
467:                MessageCreateDateComparator comparator = new MessageCreateDateComparator(
468:                        false, true);
469:
470:                Iterator itr = mbMessageLocalService.getGroupMessages(groupId,
471:                        userId, 0, _MAX_END, comparator).iterator();
472:
473:                while (itr.hasNext() && (messages.size() < max)) {
474:                    MBMessage message = (MBMessage) itr.next();
475:
476:                    if (MBMessagePermission.contains(getPermissionChecker(),
477:                            message, ActionKeys.VIEW)) {
478:
479:                        messages.add(message);
480:                    }
481:                }
482:
483:                if (messages.size() > 0) {
484:                    MBMessage message = (MBMessage) messages.get(messages
485:                            .size() - 1);
486:
487:                    name = message.getSubject();
488:                    description = message.getSubject();
489:                }
490:
491:                return exportToRSS(name, description, type, version,
492:                        displayStyle, feedURL, entryURL, messages);
493:            }
494:
495:            public MBMessage getMessage(long messageId) throws PortalException,
496:                    SystemException {
497:
498:                MBMessagePermission.check(getPermissionChecker(), messageId,
499:                        ActionKeys.VIEW);
500:
501:                return mbMessageLocalService.getMessage(messageId);
502:            }
503:
504:            public MBMessageDisplay getMessageDisplay(long messageId)
505:                    throws PortalException, SystemException {
506:
507:                MBMessagePermission.check(getPermissionChecker(), messageId,
508:                        ActionKeys.VIEW);
509:
510:                return mbMessageLocalService.getMessageDisplay(messageId);
511:            }
512:
513:            public String getThreadMessagesRSS(long threadId, int max,
514:                    String type, double version, String displayStyle,
515:                    String feedURL, String entryURL) throws PortalException,
516:                    SystemException {
517:
518:                String name = StringPool.BLANK;
519:                String description = StringPool.BLANK;
520:
521:                List messages = new ArrayList();
522:
523:                MessageCreateDateComparator comparator = new MessageCreateDateComparator(
524:                        false, true);
525:
526:                Iterator itr = mbMessageLocalService.getThreadMessages(
527:                        threadId, comparator).iterator();
528:
529:                while (itr.hasNext() && (messages.size() < max)) {
530:                    MBMessage message = (MBMessage) itr.next();
531:
532:                    if (MBMessagePermission.contains(getPermissionChecker(),
533:                            message, ActionKeys.VIEW)) {
534:
535:                        messages.add(message);
536:                    }
537:                }
538:
539:                if (messages.size() > 0) {
540:                    MBMessage message = (MBMessage) messages.get(messages
541:                            .size() - 1);
542:
543:                    name = message.getSubject();
544:                    description = message.getSubject();
545:                }
546:
547:                return exportToRSS(name, description, type, version,
548:                        displayStyle, feedURL, entryURL, messages);
549:            }
550:
551:            public void subscribeMessage(long messageId)
552:                    throws PortalException, SystemException {
553:
554:                MBMessagePermission.check(getPermissionChecker(), messageId,
555:                        ActionKeys.SUBSCRIBE);
556:
557:                mbMessageLocalService.subscribeMessage(getUserId(), messageId);
558:            }
559:
560:            public void unsubscribeMessage(long messageId)
561:                    throws PortalException, SystemException {
562:
563:                MBMessagePermission.check(getPermissionChecker(), messageId,
564:                        ActionKeys.SUBSCRIBE);
565:
566:                mbMessageLocalService
567:                        .unsubscribeMessage(getUserId(), messageId);
568:            }
569:
570:            public MBMessage updateDiscussionMessage(long groupId,
571:                    String className, long classPK, long messageId,
572:                    String subject, String body) throws PortalException,
573:                    SystemException {
574:
575:                MBDiscussionPermission.check(getPermissionChecker(), groupId,
576:                        className, classPK, ActionKeys.UPDATE_DISCUSSION);
577:
578:                return mbMessageLocalService.updateDiscussionMessage(
579:                        getUserId(), messageId, subject, body);
580:            }
581:
582:            public MBMessage updateMessage(long messageId, String subject,
583:                    String body, List files, double priority,
584:                    String[] tagsEntries) throws PortalException,
585:                    SystemException {
586:
587:                MBMessage message = mbMessageLocalService.getMessage(messageId);
588:
589:                MBMessagePermission.check(getPermissionChecker(), messageId,
590:                        ActionKeys.UPDATE);
591:
592:                if (!MBCategoryPermission.contains(getPermissionChecker(),
593:                        message.getCategoryId(), ActionKeys.ADD_FILE)) {
594:
595:                    files.clear();
596:                }
597:
598:                if (!MBCategoryPermission.contains(getPermissionChecker(),
599:                        message.getCategoryId(),
600:                        ActionKeys.UPDATE_THREAD_PRIORITY)) {
601:
602:                    MBThread thread = mbThreadLocalService.getThread(message
603:                            .getThreadId());
604:
605:                    priority = thread.getPriority();
606:                }
607:
608:                return mbMessageLocalService.updateMessage(getUserId(),
609:                        messageId, subject, body, files, priority, tagsEntries,
610:                        null, null);
611:            }
612:
613:            public MBMessage updateMessage(long messageId, String subject,
614:                    String body, List files, double priority,
615:                    String[] tagsEntries, PortletPreferences prefs,
616:                    ThemeDisplay themeDisplay) throws PortalException,
617:                    SystemException {
618:
619:                MBMessage message = mbMessageLocalService.getMessage(messageId);
620:
621:                MBMessagePermission.check(getPermissionChecker(), messageId,
622:                        ActionKeys.UPDATE);
623:
624:                if (!MBCategoryPermission.contains(getPermissionChecker(),
625:                        message.getCategoryId(), ActionKeys.ADD_FILE)) {
626:
627:                    files.clear();
628:                }
629:
630:                if (!MBCategoryPermission.contains(getPermissionChecker(),
631:                        message.getCategoryId(),
632:                        ActionKeys.UPDATE_THREAD_PRIORITY)) {
633:
634:                    MBThread thread = mbThreadLocalService.getThread(message
635:                            .getThreadId());
636:
637:                    priority = thread.getPriority();
638:                }
639:
640:                return mbMessageLocalService.updateMessage(getUserId(),
641:                        messageId, subject, body, files, priority, tagsEntries,
642:                        prefs, themeDisplay);
643:            }
644:
645:            protected void checkReplyToPermission(long categoryId,
646:                    long parentMessageId) throws PortalException,
647:                    SystemException {
648:
649:                if (parentMessageId > 0) {
650:                    if (MBCategoryPermission.contains(getPermissionChecker(),
651:                            categoryId, ActionKeys.ADD_MESSAGE)) {
652:
653:                        return;
654:                    }
655:
656:                    MBMessage parentMessage = mbMessagePersistence
657:                            .fetchByPrimaryKey(parentMessageId);
658:
659:                    if ((parentMessage == null)
660:                            || !MBCategoryPermission.contains(
661:                                    getPermissionChecker(), categoryId,
662:                                    ActionKeys.REPLY_TO_MESSAGE)) {
663:
664:                        throw new PrincipalException();
665:                    }
666:                } else {
667:                    MBCategoryPermission.check(getPermissionChecker(),
668:                            categoryId, ActionKeys.ADD_MESSAGE);
669:                }
670:            }
671:
672:            protected String exportToRSS(String name, String description,
673:                    String type, double version, String displayStyle,
674:                    String feedURL, String entryURL, List messages)
675:                    throws SystemException {
676:
677:                SyndFeed syndFeed = new SyndFeedImpl();
678:
679:                syndFeed.setFeedType(type + "_" + version);
680:                syndFeed.setTitle(name);
681:                syndFeed.setLink(feedURL);
682:                syndFeed.setDescription(description);
683:
684:                List entries = new ArrayList();
685:
686:                syndFeed.setEntries(entries);
687:
688:                Iterator itr = messages.iterator();
689:
690:                while (itr.hasNext()) {
691:                    MBMessage message = (MBMessage) itr.next();
692:
693:                    String author = PortalUtil.getUserName(message.getUserId(),
694:                            message.getUserName());
695:
696:                    String value = null;
697:
698:                    if (displayStyle.equals(RSSUtil.DISPLAY_STYLE_ABSTRACT)) {
699:                        value = StringUtil.shorten(Html.stripHtml(message
700:                                .getBody()), _RSS_ABSTRACT_LENGTH,
701:                                StringPool.BLANK);
702:                    } else {
703:                        value = message.getBody();
704:                    }
705:
706:                    SyndEntry syndEntry = new SyndEntryImpl();
707:
708:                    if (!message.isAnonymous()) {
709:                        syndEntry.setAuthor(author);
710:                    }
711:
712:                    syndEntry.setTitle(message.getSubject());
713:                    syndEntry.setLink(entryURL + "&messageId="
714:                            + message.getMessageId());
715:                    syndEntry.setPublishedDate(message.getCreateDate());
716:
717:                    SyndContent syndContent = new SyndContentImpl();
718:
719:                    syndContent.setType("html");
720:                    syndContent.setValue(value);
721:
722:                    syndEntry.setDescription(syndContent);
723:
724:                    entries.add(syndEntry);
725:                }
726:
727:                try {
728:                    return RSSUtil.export(syndFeed);
729:                } catch (FeedException fe) {
730:                    throw new SystemException(fe);
731:                } catch (IOException ioe) {
732:                    throw new SystemException(ioe);
733:                }
734:            }
735:
736:            private static final int _MAX_END = 200;
737:
738:            private static final int _RSS_ABSTRACT_LENGTH = GetterUtil
739:                    .getInteger(PropsUtil
740:                            .get(PropsUtil.MESSAGE_BOARDS_RSS_ABSTRACT_LENGTH));
741:
742:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.