{"id":873,"date":"2006-11-08T22:28:27","date_gmt":"2006-11-09T06:28:27","guid":{"rendered":"http:\/\/cephas.net\/blog\/2006\/11\/08\/rome-custom-modules-publishdate-and-rss\/"},"modified":"2006-11-11T13:23:58","modified_gmt":"2006-11-11T21:23:58","slug":"rome-custom-modules-publishdate-and-rss","status":"publish","type":"post","link":"https:\/\/cephas.net\/blog\/2006\/11\/08\/rome-custom-modules-publishdate-and-rss\/","title":{"rendered":"ROME, custom modules, publishdate and RSS"},"content":{"rendered":"<p>At work, I&#8217;ve taken on the work of migrating our RSS feeds currently being produced using JSP to <a href=\"https:\/\/rome.dev.java.net\/\">ROME<\/a>. Since we&#8217;ve added a few custom elements to the feeds available in Jive Forums (things like message and thread counts), I&#8217;m taking advantage of the feature in ROME that gives you the ability to <a href=\"http:\/\/wiki.java.net\/bin\/view\/Javawsxml\/Rome05TutorialSampleModule\">programtically define namespaces<\/a> in your RSS 2.0, Atom 0.3 and Atom 1.0 feeds (examples: the <a href=\"http:\/\/wiki.java.net\/bin\/view\/Javawsxml\/ITunes\">iTunes module<\/a> and the <a href=\"http:\/\/wiki.java.net\/bin\/view\/Javawsxml\/OpenSearch\">OpenSearch module<\/a>).  Anyway, the code I wrote to add an item to the list of available items in a feed looked something like this:<\/p>\n<pre>\r\n...\r\nentry = new SyndEntryImpl();\r\nentry.setTitle(thread.getSubject());\r\nentry.setLink(\"http:\/\/mysite.com\/community\/threads.jspa?id=\" + \r\n   thread.getID());\r\nentry.setUpdatedDate(thread.getModificationDate());\r\nentry.setPublishedDate(thread.getCreationDate());\r\n...\r\nJiveForumsModule module = new JiveForumsModuleImpl();\r\nmodule.setReplyCount(thread.getReplyCount());\r\nList<Module> modules = new ArrayList<Module>();\r\nmodules.add(module);\r\nentry.setModules(modules);\r\n...\r\n<\/pre>\n<p>This code works, but if you view the feed, you don&#8217;t get a publish date on the item.  I dug into the ROME source code a bit and found that the <a href=\"https:\/\/rome.dev.java.net\/apidocs\/0_8\/com\/sun\/syndication\/feed\/synd\/SyndEntryImpl.html#getPublishedDate()\">publish date is stored as part of the Dublin Core module<\/a>, which I came to find out is a &#8216;special&#8217; module that always exists on a SyndEntryImpl object. Take a look at the implementation of the getModules() method on the SyndEntryImpl class:<\/p>\n<pre>\r\npublic List getModules() {\r\n  if  (_modules==null) {\r\n    _modules=new ArrayList();\r\n  }\r\n  if (ModuleUtils.getModule(_modules,DCModule.URI)==null) {\r\n    _modules.add(new DCModuleImpl());\r\n  }\r\n  return _modules;\r\n}\r\n<\/pre>\n<p>See how the method automatically injects a DCModuleImpl into the _modules property if the DCModule doesn&#8217;t exist?   Long story short, the code I wrote blew away the <code>_modules<\/code> property on the SyndEntryImpl instance which contained a single DCModule which itself contained the publishedDate date instance.  So by the time the feed was produced, the publish date I set on each SyndEntry was long gone. I should have written my code like this:<\/p>\n<pre>\r\nJiveForumsModule module = new JiveForumsModuleImpl();\r\nmodule.setReplyCount(thread.getReplyCount());\r\nentry.getModules().add(module);\r\n<\/pre>\n<p>Better yet, the ROME team could have done two things:<\/p>\n<ol>\n<li>Added documentation to the setModules(List modules) method that pointed out that any information in the existing DCModule instance will be lost if the provided list doesn&#8217;t contain the existing DCModule instance.<\/li>\n<li>Added a method to the SyndEntry interface called addModule(Module module).<\/li>\n<\/ol>\n<p>Open source: I&#8217;m lovin it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>At work, I&#8217;ve taken on the work of migrating our RSS feeds currently being produced using JSP to ROME. Since we&#8217;ve added a few custom elements to the feeds available in Jive Forums (things like message and thread counts), I&#8217;m taking advantage of the feature in ROME that gives you the ability to programtically define &hellip; <a href=\"https:\/\/cephas.net\/blog\/2006\/11\/08\/rome-custom-modules-publishdate-and-rss\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ROME, custom modules, publishdate and RSS<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,2,32],"tags":[],"_links":{"self":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/873"}],"collection":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/comments?post=873"}],"version-history":[{"count":0,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/posts\/873\/revisions"}],"wp:attachment":[{"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/media?parent=873"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/categories?post=873"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cephas.net\/blog\/wp-json\/wp\/v2\/tags?post=873"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}