Source Code Cross Referenced for IssueFeed.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » feeds » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.feeds 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.feeds;
002:
003:        import java.io.IOException;
004:        import java.util.ArrayList;
005:        import java.util.Date;
006:        import java.util.Iterator;
007:        import java.util.List;
008:
009:        import org.apache.torque.TorqueException;
010:        import org.tigris.scarab.om.Activity;
011:        import org.tigris.scarab.om.ActivitySet;
012:        import org.tigris.scarab.om.Issue;
013:        import org.tigris.scarab.tools.ScarabLocalizationTool;
014:        import org.tigris.scarab.tools.ScarabToolManager;
015:        import org.tigris.scarab.util.ScarabLink;
016:
017:        import com.sun.syndication.feed.synd.SyndContent;
018:        import com.sun.syndication.feed.synd.SyndContentImpl;
019:        import com.sun.syndication.feed.synd.SyndEntry;
020:        import com.sun.syndication.feed.synd.SyndEntryImpl;
021:        import com.sun.syndication.feed.synd.SyndFeed;
022:        import com.sun.syndication.feed.synd.SyndFeedImpl;
023:        import com.sun.syndication.io.FeedException;
024:
025:        /**
026:         * Converts a Issue to an RSS feed.
027:         * 
028:         * @todo improve what is shown to a user
029:         * @author Eric Pugh
030:         *  
031:         */
032:        public class IssueFeed implements  Feed {
033:
034:            private Issue issue;
035:
036:            private ScarabLink scarabLink;
037:            private ScarabToolManager scarabToolManager;
038:            private ScarabLocalizationTool l10nTool;
039:
040:            public IssueFeed(Issue issue, ScarabLink scarabLink,
041:                    ScarabToolManager scarabToolManager,
042:                    ScarabLocalizationTool l10nTool) {
043:                this .issue = issue;
044:                this .scarabLink = scarabLink;
045:                this .scarabToolManager = scarabToolManager;
046:                this .l10nTool = l10nTool;
047:            }
048:
049:            public SyndFeed getFeed() throws IOException, FeedException,
050:                    TorqueException, Exception {
051:
052:                SyndFeed feed = new SyndFeedImpl();
053:
054:                String title = issue.getUniqueId() + ": "
055:                        + issue.getDefaultText();
056:                feed.setTitle(title);
057:                String link = scarabLink.getIssueIdAbsoluteLink(issue)
058:                        .toString();
059:                feed.setLink(link);
060:                feed.setDescription(title);
061:
062:                List entries = new ArrayList();
063:                List allActivities = issue.getActivity(true);
064:
065:                for (Iterator i = allActivities.iterator(); i.hasNext();) {
066:                    SyndEntry entry;
067:                    SyndContent description;
068:
069:                    Activity activity = (Activity) i.next();
070:
071:                    ActivitySet activitySet = activity.getActivitySet();
072:                    Date date = activitySet.getCreatedDate();
073:                    entry = new SyndEntryImpl();
074:
075:                    entry.setPublishedDate(date);
076:
077:                    description = new SyndContentImpl();
078:                    description.setType("text/html");
079:
080:                    StringBuffer desc = new StringBuffer();
081:                    String activityDesc = activity
082:                            .getDescription(this .l10nTool);
083:                    desc.append("<b>Description:</b>" + activityDesc + "<br/>");
084:                    desc
085:                            .append("<b>Reason:</b>"
086:                                    + activitySet.getActivityReason(l10nTool)
087:                                    + "<br/>");
088:                    entry.setAuthor(activitySet.getCreator().getName());
089:
090:                    description.setValue(desc.toString());
091:
092:                    String entryTitle = createEntryTitle(activity);
093:                    entry.setTitle(entryTitle);
094:
095:                    entry.setDescription(description);
096:
097:                    //The hashCode is a cheap trick to have a unique link tag in the RSS feed
098:                    //to help those reader as ThunderBird that use the link to check for new items
099:                    entry.setLink(link + "?hash=" + entry.hashCode());
100:
101:                    entries.add(entry);
102:                }
103:
104:                feed.setEntries(entries);
105:
106:                return feed;
107:            }
108:
109:            /**
110:             * Just a method to isolate the logic for the entry naming.
111:             * It is just a substring of the activity description
112:             * @param activity the activity we want to create the title for
113:             * @return the entry title
114:             */
115:            private String createEntryTitle(Activity activity) {
116:                String activityDesc = activity.getDescription(this .l10nTool);
117:                String entryTitle = null;
118:                int maxTitleLength = 64;
119:                int activityLength = activityDesc.length();
120:                entryTitle = activityDesc.substring(0,
121:                        (activityLength >= maxTitleLength) ? maxTitleLength
122:                                : activityLength);
123:                return entryTitle;
124:            }
125:
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.