[jboss-svn-commits] JBL Code SVN: r6563 - in labs/shotoku/trunk: . shotoku-admin shotoku-aop shotoku-base shotoku-blog shotoku-blog/src shotoku-blog/src/etc/META-INF shotoku-blog/src/java/org/jboss/blog shotoku-blog/src/java/org/jboss/blog/model shotoku-blog/src/java/org/jboss/blog/rome shotoku-blog/src/java/org/jboss/blog/service shotoku-blog/src/java/org/jboss/blog/service/model shotoku-blog/src/java/org/jboss/blog/service/name shotoku-blog/src/java/org/jboss/blog/tools shotoku-blog/src/rome shotoku-example shotoku-example/src/java/org/jboss/shotoku/example shotoku-feeds shotoku-file-access shotoku-files shotoku-jcr shotoku-portal shotoku-svn shotoku-tags shotoku-test shotoku-user shotoku-web
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Oct 3 18:06:47 EDT 2006
Author: adamw
Date: 2006-10-03 18:06:31 -0400 (Tue, 03 Oct 2006)
New Revision: 6563
Added:
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModel.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModelDoesNotExistException.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModule.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleGenerator.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleImpl.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleParser.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/BlogModelService.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/CachingBlogModelService.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/RomeParsingBlogModelService.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/tools/
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/tools/BlogTools.java
labs/shotoku/trunk/shotoku-blog/src/rome/
labs/shotoku/trunk/shotoku-blog/src/rome/rome.properties
Removed:
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java
Modified:
labs/shotoku/trunk/shotoku-admin/shotoku-admin.iml
labs/shotoku/trunk/shotoku-aop/shotoku-aop.iml
labs/shotoku/trunk/shotoku-base/shotoku-base.iml
labs/shotoku/trunk/shotoku-blog/shotoku-blog.iml
labs/shotoku/trunk/shotoku-blog/src/etc/META-INF/jboss-service.xml
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/BlogService.java
labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java
labs/shotoku/trunk/shotoku-example/shotoku-example.iml
labs/shotoku/trunk/shotoku-example/src/java/org/jboss/shotoku/example/ExampleEmbedded.java
labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml
labs/shotoku/trunk/shotoku-file-access/shotoku-file-access.iml
labs/shotoku/trunk/shotoku-files/shotoku-files.iml
labs/shotoku/trunk/shotoku-jcr/shotoku-jcr.iml
labs/shotoku/trunk/shotoku-portal/shotoku-portal.iml
labs/shotoku/trunk/shotoku-svn/shotoku-svn.iml
labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml
labs/shotoku/trunk/shotoku-test/shotoku-test.iml
labs/shotoku/trunk/shotoku-user/shotoku-user.iml
labs/shotoku/trunk/shotoku-web/shotoku-web.iml
labs/shotoku/trunk/shotoku.iml
Log:
http://jira.jboss.com/jira/browse/JBSHOTOKU-94
Modified: labs/shotoku/trunk/shotoku-admin/shotoku-admin.iml
===================================================================
--- labs/shotoku/trunk/shotoku-admin/shotoku-admin.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-admin/shotoku-admin.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-aop/shotoku-aop.iml
===================================================================
--- labs/shotoku/trunk/shotoku-aop/shotoku-aop.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-aop/shotoku-aop.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-base/shotoku-base.iml
===================================================================
--- labs/shotoku/trunk/shotoku-base/shotoku-base.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-base/shotoku-base.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-blog/shotoku-blog.iml
===================================================================
--- labs/shotoku/trunk/shotoku-blog/shotoku-blog.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/shotoku-blog.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -11,6 +11,8 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="myfaces" level="application" />
<orderEntry type="library" name="portal" level="application" />
+ <orderEntry type="library" name="feeds" level="application" />
+ <orderEntry type="library" name="jboss" level="application" />
<orderEntryProperties />
</component>
</module>
Modified: labs/shotoku/trunk/shotoku-blog/src/etc/META-INF/jboss-service.xml
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/etc/META-INF/jboss-service.xml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/etc/META-INF/jboss-service.xml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -7,12 +7,28 @@
xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
<xmbean/>
<attribute name="IdPreferenceName">blogId</attribute>
- <attribute name="IdInitParameterName">blogId</attribute>
<attribute name="CategoryPreferenceName">blogCategory</attribute>
- <attribute name="CategoryInitParameterName">blogCategory</attribute>
</mbean>
<mbean
+ code="org.jboss.blog.service.model.CachingBlogModelService"
+ name="blog:service=Model"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends
+ optional-attribute-name="DelegateModelService"
+ proxy-type="attribute">blog:service=Name</depends>
+ </mbean>
+ <mbean
+ code="org.jboss.blog.service.model.RomeParsingBlogModelService"
+ name="blog:service=RomeParsingModel"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">
+ <xmbean/>
+ </mbean>
+
+ <mbean
code="org.jboss.blog.service.BlogService"
name="blog:service=Main"
xmbean-dd=""
@@ -21,5 +37,8 @@
<depends
optional-attribute-name="NameService"
proxy-type="attribute">blog:service=Name</depends>
+ <depends
+ optional-attribute-name="ModelService"
+ proxy-type="attribute">blog:service=Model</depends>
</mbean>
</server>
\ No newline at end of file
Deleted: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,71 +0,0 @@
-package org.jboss.blog.model;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * A class representing a blog, that is, a collection of blog entries, together
- * with blog-wide information.
- * @author Adam Warski (adamw at aster.pl)
- */
-public class BlogEntries {
- private String author;
- private String title;
- private String description;
- private Date created;
- private String link;
- private List<BlogEntry> entries;
-
- public BlogEntries(String author, String title, String description,
- Date created, String link, List<BlogEntry> entries) {
- this.author = author;
- this.title = title;
- this.description = description;
- this.created = created;
- this.link = link;
- this.entries = entries;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public String getTitle() {
- return title;
- }
-
- public String getDescription() {
- return description;
- }
-
- public Date getCreated() {
- return created;
- }
-
- public String getLink() {
- return link;
- }
-
- public List<BlogEntry> getEntries() {
- return entries;
- }
-
- public int getEntryIndex(String guid)
- throws BlogEntryDoesNotExistException {
- int i = 0;
- for (BlogEntry entry : getEntries()) {
- if (entry.getGuid().equals(guid)) {
- return i;
- }
-
- i++;
- }
-
- throw new BlogEntryDoesNotExistException(guid);
- }
-
- public BlogEntry getEntry(String guid)
- throws BlogEntryDoesNotExistException {
- return getEntries().get(getEntryIndex(guid));
- }
-}
Copied: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModel.java (from rev 6539, labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java)
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java 2006-10-02 21:48:17 UTC (rev 6539)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModel.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,71 @@
+package org.jboss.blog.model;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * A class representing a blog, that is, a collection of blog entries, together
+ * with blog-wide information.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class BlogModel {
+ private String author;
+ private String title;
+ private String description;
+ private Date created;
+ private String link;
+ private List<BlogEntry> entries;
+
+ public BlogModel(String author, String title, String description,
+ Date created, String link, List<BlogEntry> entries) {
+ this.author = author;
+ this.title = title;
+ this.description = description;
+ this.created = created;
+ this.link = link;
+ this.entries = entries;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public List<BlogEntry> getEntries() {
+ return entries;
+ }
+
+ public int getEntryIndex(String guid)
+ throws BlogEntryDoesNotExistException {
+ int i = 0;
+ for (BlogEntry entry : getEntries()) {
+ if (entry.getGuid().equals(guid)) {
+ return i;
+ }
+
+ i++;
+ }
+
+ throw new BlogEntryDoesNotExistException(guid);
+ }
+
+ public BlogEntry getEntry(String guid)
+ throws BlogEntryDoesNotExistException {
+ return getEntries().get(getEntryIndex(guid));
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModelDoesNotExistException.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModelDoesNotExistException.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogModelDoesNotExistException.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,22 @@
+package org.jboss.blog.model;
+
+/**
+ * An exception thrown when a blog model is requested, which does not exist.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class BlogModelDoesNotExistException extends Exception {
+ public BlogModelDoesNotExistException() {
+ }
+
+ public BlogModelDoesNotExistException(String message) {
+ super(message);
+ }
+
+ public BlogModelDoesNotExistException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public BlogModelDoesNotExistException(Throwable cause) {
+ super(cause);
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModule.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModule.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModule.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,14 @@
+package org.jboss.blog.rome;
+
+import com.sun.syndication.feed.module.Module;
+import com.sun.syndication.feed.CopyFrom;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public interface CommentRssModule extends Module, CopyFrom {
+ public static final String URI = "http://wellformedweb.org/CommentAPI/";
+
+ public String getCommentRss();
+ public void setCommentRss(String commentRss);
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleGenerator.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleGenerator.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleGenerator.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,58 @@
+package org.jboss.blog.rome;
+
+import com.sun.syndication.io.ModuleGenerator;
+import com.sun.syndication.feed.module.Module;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Collections;
+
+import org.jdom.Namespace;
+import org.jdom.Element;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class CommentRssModuleGenerator implements ModuleGenerator {
+ private static final Namespace COMM_RSS_NS =
+ Namespace.getNamespace("wfw", CommentRssModule.URI);
+
+ public String getNamespaceUri() {
+ return CommentRssModule.URI;
+ }
+
+ private static Set NAMESPACES;
+
+ static {
+ Set nss = new HashSet();
+ //noinspection unchecked
+ nss.add(CommentRssModuleGenerator.COMM_RSS_NS);
+ //noinspection unchecked
+ CommentRssModuleGenerator.NAMESPACES = Collections.unmodifiableSet(nss);
+ }
+
+ public Set getNamespaces() {
+ return CommentRssModuleGenerator.NAMESPACES;
+ }
+
+ public void generate(Module module, Element element) {
+ // this is not necessary, it is done to avoid the namespace definition in every item.
+ Element root = element;
+ while (root.getParent()!=null && root.getParent() instanceof Element) {
+ root = (Element) element.getParent();
+ }
+ root.addNamespaceDeclaration(CommentRssModuleGenerator.COMM_RSS_NS);
+
+ CommentRssModule crm = (CommentRssModule) module;
+ if (crm.getCommentRss() != null) {
+ element.addContent(generateSimpleElement("commentRss",
+ crm.getCommentRss()));
+ }
+ }
+
+ protected Element generateSimpleElement(String name, String value) {
+ Element element = new Element(name, CommentRssModuleGenerator.COMM_RSS_NS);
+ element.addContent(value);
+ return element;
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleImpl.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleImpl.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleImpl.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,32 @@
+package org.jboss.blog.rome;
+
+import com.sun.syndication.feed.module.ModuleImpl;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class CommentRssModuleImpl extends ModuleImpl
+ implements CommentRssModule {
+ private String commentRss;
+
+ public CommentRssModuleImpl() {
+ super(CommentRssModule.class, CommentRssModule.URI);
+ }
+
+ public String getCommentRss() {
+ return commentRss;
+ }
+
+ public void setCommentRss(String commentRss) {
+ this.commentRss = commentRss;
+ }
+
+ public Class getInterface() {
+ return CommentRssModule.class;
+ }
+
+ public void copyFrom(Object obj) {
+ CommentRssModule crm = (CommentRssModule) obj;
+ setCommentRss(crm.getCommentRss());
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleParser.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleParser.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/rome/CommentRssModuleParser.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,31 @@
+package org.jboss.blog.rome;
+
+import com.sun.syndication.io.ModuleParser;
+import com.sun.syndication.feed.module.Module;
+import org.jdom.Namespace;
+import org.jdom.Element;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class CommentRssModuleParser implements ModuleParser {
+ private static final Namespace COMM_RSS_NS =
+ Namespace.getNamespace("wfw", CommentRssModule.URI);
+
+ public String getNamespaceUri() {
+ return CommentRssModule.URI;
+ }
+
+ public Module parse(Element dcRoot) {
+ boolean foundSomething = false;
+ CommentRssModule fm = new CommentRssModuleImpl();
+
+ Element e = dcRoot.getChild("commentRss", CommentRssModuleParser.COMM_RSS_NS);
+ if (e != null) {
+ foundSomething = true;
+ fm.setCommentRss(e.getText());
+ }
+
+ return (foundSomething) ? fm : null;
+ }
+}
Modified: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/BlogService.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/BlogService.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/BlogService.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -2,6 +2,7 @@
import org.jboss.portal.common.system.AbstractJBossService;
import org.jboss.blog.service.name.BlogNameService;
+import org.jboss.blog.service.model.BlogModelService;
/**
* A central point tieing all other blog servcies and providing a way to access
@@ -14,6 +15,7 @@
}
private BlogNameService nameService;
+ private BlogModelService modelService;
public BlogNameService getNameService() {
return nameService;
@@ -22,4 +24,12 @@
public void setNameService(BlogNameService nameService) {
this.nameService = nameService;
}
+
+ public BlogModelService getModelService() {
+ return modelService;
+ }
+
+ public void setModelService(BlogModelService modelService) {
+ this.modelService = modelService;
+ }
}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/BlogModelService.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/BlogModelService.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/BlogModelService.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,22 @@
+package org.jboss.blog.service.model;
+
+import org.jboss.blog.BlogName;
+import org.jboss.blog.model.BlogModel;
+import org.jboss.blog.model.BlogModelDoesNotExistException;
+
+/**
+ * A service which enables to obtain a blog model (parsed blog information and
+ * entries), having a blog name.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public interface BlogModelService {
+ /**
+ * Basing on the given blog name, reads (parses/ creates/ etc) a blog
+ * model.
+ * @param name Name of the blog for which the model should be read.
+ * @return A model of a blog with the given name.
+ * @throws org.jboss.blog.model.BlogModelDoesNotExistException If a blog
+ * with the given name couldn't be found.
+ */
+ public BlogModel getBlogModel(BlogName name) throws BlogModelDoesNotExistException;
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/CachingBlogModelService.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/CachingBlogModelService.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/CachingBlogModelService.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,30 @@
+package org.jboss.blog.service.model;
+
+import org.jboss.blog.model.BlogModel;
+import org.jboss.blog.model.BlogModelDoesNotExistException;
+import org.jboss.blog.BlogName;
+
+/**
+ * A blog model service which caches models returned by another blog model
+ * service to avoid, for example, unnecessary feed parsing.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class CachingBlogModelService implements BlogModelService {
+ public CachingBlogModelService() {
+
+ }
+
+ public BlogModel getBlogModel(BlogName name) throws BlogModelDoesNotExistException {
+ return delegateModelService.getBlogModel(name);
+ }
+
+ private BlogModelService delegateModelService;
+
+ public BlogModelService getDelegateModelService() {
+ return delegateModelService;
+ }
+
+ public void setDelegateModelService(BlogModelService delegateModelService) {
+ this.delegateModelService = delegateModelService;
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/RomeParsingBlogModelService.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/RomeParsingBlogModelService.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/model/RomeParsingBlogModelService.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,73 @@
+package org.jboss.blog.service.model;
+
+import org.jboss.blog.model.BlogModel;
+import org.jboss.blog.model.BlogModelDoesNotExistException;
+import org.jboss.blog.model.BlogEntry;
+import org.jboss.blog.BlogName;
+import org.jboss.blog.rome.CommentRssModule;
+import org.jboss.blog.tools.BlogTools;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.net.URL;
+import java.io.IOException;
+
+import com.sun.syndication.io.SyndFeedInput;
+import com.sun.syndication.io.XmlReader;
+import com.sun.syndication.io.FeedException;
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.feed.synd.SyndEntry;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class RomeParsingBlogModelService implements BlogModelService {
+ public RomeParsingBlogModelService() {
+
+ }
+
+ public BlogModel getBlogModel(BlogName name) throws BlogModelDoesNotExistException {
+ if (name.getId() == null) {
+ throw new BlogModelDoesNotExistException("No blog selected (null blog id)");
+ }
+
+ // Parsing the feed, which's address is the id of the selected blog.
+ SyndFeedInput input = new SyndFeedInput();
+ SyndFeed inFeed;
+ try {
+ inFeed = input.build(new XmlReader(new URL(name.getId()).openStream()));
+ } catch (IOException e) {
+ throw new BlogModelDoesNotExistException(e);
+ } catch (FeedException e) {
+ throw new BlogModelDoesNotExistException(e);
+ }
+
+ List<BlogEntry> entries = new ArrayList<BlogEntry>();
+
+ String defaultAuthor = inFeed.getAuthor();
+ for (Object o : inFeed.getEntries()) {
+ SyndEntry entry = (SyndEntry) o;
+
+ CommentRssModule commRssModule = (CommentRssModule)
+ entry.getModule("http://wellformedweb.org/CommentAPI/");
+ String commentsRss = null;
+ if (commRssModule != null) {
+ commentsRss = commRssModule.getCommentRss();
+ if (commentsRss != null) {
+ commentsRss = commentsRss.trim();
+ }
+ }
+
+ String author = entry.getAuthor();
+ entries.add(new BlogEntry(
+ BlogTools.isEmpty(author) ? defaultAuthor : author,
+ entry.getTitle(), entry.getDescription().getValue(),
+ entry.getPublishedDate(), entry.getLink(),
+ entry.getUri(), commentsRss));
+ }
+
+ return new BlogModel(inFeed.getAuthor(), inFeed.getTitle(),
+ inFeed.getDescription(), inFeed.getPublishedDate(),
+ inFeed.getLink(), entries);
+ }
+}
Modified: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -6,39 +6,26 @@
import javax.portlet.PortletRequest;
/**
- * A name service which reads the blog name from portlet preferences. Id these
- * preferences are not set, the blog name is read from init paremters.
+ * A name service which reads the blog name from portlet preferences.
* @author Adam Warski (adamw at aster.pl)
*/
public class PortletPreferencesBlogNameService extends AbstractJBossService
implements BlogNameService {
private String idPreferenceName;
- private String idInitParameterName;
private String categoryPreferenceName;
- private String categoryInitParameterName;
public PortletPreferencesBlogNameService() {
}
/**
- * Using the given request object, tries to read a given portlet preference, using
- * as the default value an init parameter of the given name.
+ * Using the given request object, tries to read a given portlet preference.
* @param req Request from which to read.
* @param prefName Name of the preference to read.
- * @param initParamName Name of the initial parameter name, which value will be
- * returned in case the given preference is not set.
- * @return Value of the given portlet preference or if it is not set, value of the
- * given initial parameter.
+ * @return Value of the given portlet preference.
*/
- private String getPreference(PortletRequest req, String prefName, String initParamName) {
- String pref = req.getPreferences().getValue(prefName, null);
-
- if (pref == null) {
- pref = req.getPortletSession().getPortletContext().getInitParameter(initParamName);
- }
-
- return pref;
+ private String getPreference(PortletRequest req, String prefName) {
+ return req.getPreferences().getValue(prefName, null);
}
public BlogName getBlogName(Object request) {
@@ -49,8 +36,8 @@
}
PortletRequest req = (PortletRequest) request;
- return new BlogName(getPreference(req, idPreferenceName, idInitParameterName),
- getPreference(req, categoryPreferenceName, categoryInitParameterName));
+ return new BlogName(getPreference(req, idPreferenceName),
+ getPreference(req, categoryPreferenceName));
}
public String getIdPreferenceName() {
@@ -61,14 +48,6 @@
this.idPreferenceName = idPreferenceName;
}
- public String getIdInitParameterName() {
- return idInitParameterName;
- }
-
- public void setIdInitParameterName(String idInitParameterName) {
- this.idInitParameterName = idInitParameterName;
- }
-
public String getCategoryPreferenceName() {
return categoryPreferenceName;
}
@@ -76,12 +55,4 @@
public void setCategoryPreferenceName(String categoryPreferenceName) {
this.categoryPreferenceName = categoryPreferenceName;
}
-
- public String getCategoryInitParameterName() {
- return categoryInitParameterName;
- }
-
- public void setCategoryInitParameterName(String categoryInitParameterName) {
- this.categoryInitParameterName = categoryInitParameterName;
- }
}
Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/tools/BlogTools.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/tools/BlogTools.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/tools/BlogTools.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,17 @@
+package org.jboss.blog.tools;
+
+/**
+ * Various common and usefull functions.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class BlogTools {
+ /**
+ * Checks if the given string is either null or empty.
+ * @param s String to check for emptiness.
+ * @return True iff the given string is either null or empty (represents an
+ * empty sequence of characters).
+ */
+ public static boolean isEmpty(String s) {
+ return (s == null) || s.equals("");
+ }
+}
Added: labs/shotoku/trunk/shotoku-blog/src/rome/rome.properties
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/rome/rome.properties 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-blog/src/rome/rome.properties 2006-10-03 22:06:31 UTC (rev 6563)
@@ -0,0 +1,119 @@
+#
+# Copyright 2004 Sun Microsystems, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+
+# Feed Parser implementation classes
+#
+WireFeedParser.classes=com.sun.syndication.io.impl.RSS090Parser \
+ com.sun.syndication.io.impl.RSS091NetscapeParser \
+ com.sun.syndication.io.impl.RSS091UserlandParser \
+ com.sun.syndication.io.impl.RSS092Parser \
+ com.sun.syndication.io.impl.RSS093Parser \
+ com.sun.syndication.io.impl.RSS094Parser \
+ com.sun.syndication.io.impl.RSS10Parser \
+ com.sun.syndication.io.impl.RSS20wNSParser \
+ com.sun.syndication.io.impl.RSS20Parser \
+ com.sun.syndication.io.impl.Atom03Parser
+
+# Parsers for Atom 0.3 feed modules
+#
+atom_0.3.feed.ModuleParser.classes=com.sun.syndication.io.impl.SyModuleParser \
+ com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for Atom 0.3 entry modules
+#
+atom_0.3.item.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 1.0 feed modules
+#
+rss_1.0.feed.ModuleParser.classes=com.sun.syndication.io.impl.SyModuleParser \
+ com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 1.0 item modules
+#
+rss_1.0.item.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 2.0 (w/NS) feed modules
+#
+rss_2.0wNS.feed.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 2.0 (w/NS) item modules
+#
+rss_2.0wNS.item.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 2.0 feed modules
+#
+rss_2.0.feed.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser
+
+# Parsers for RSS 2.0 item modules
+#
+rss_2.0.item.ModuleParser.classes=com.sun.syndication.io.impl.DCModuleParser,org.jboss.shotoku.feeds.rome.CommentRssModuleParser
+
+
+
+
+# Feed Generator implementation classes
+#
+WireFeedGenerator.classes=com.sun.syndication.io.impl.RSS090Generator \
+ com.sun.syndication.io.impl.RSS091NetscapeGenerator \
+ com.sun.syndication.io.impl.RSS091UserlandGenerator \
+ com.sun.syndication.io.impl.RSS092Generator \
+ com.sun.syndication.io.impl.RSS093Generator \
+ com.sun.syndication.io.impl.RSS094Generator \
+ com.sun.syndication.io.impl.RSS10Generator \
+ com.sun.syndication.io.impl.RSS20Generator \
+ com.sun.syndication.io.impl.Atom03Generator
+
+# Generators for Atom 0.3 feed modules
+#
+atom_0.3.feed.ModuleGenerator.classes=com.sun.syndication.io.impl.SyModuleGenerator \
+ com.sun.syndication.io.impl.DCModuleGenerator
+
+# Generators for Atom 0.3 entry modules
+#
+atom_0.3.item.ModuleGenerator.classes=com.sun.syndication.io.impl.DCModuleGenerator
+
+# Generators for RSS 1.0 feed modules
+#
+rss_1.0.feed.ModuleGenerator.classes=com.sun.syndication.io.impl.SyModuleGenerator \
+ com.sun.syndication.io.impl.DCModuleGenerator
+
+# Generators for RSS_1.0 entry modules
+#
+rss_1.0.item.ModuleGenerator.classes=com.sun.syndication.io.impl.DCModuleGenerator
+
+# Generators for RSS 2.0 feed modules
+#
+rss_2.0.feed.ModuleGenerator.classes=com.sun.syndication.io.impl.DCModuleGenerator
+
+# Generators for RSS_2.0 entry modules
+#
+rss_2.0.item.ModuleGenerator.classes=com.sun.syndication.io.impl.DCModuleGenerator,org.jboss.shotoku.feeds.rome.CommentRssModuleGenerator
+
+
+
+
+# Feed Conversor implementation classes
+#
+Converter.classes=com.sun.syndication.feed.synd.impl.ConverterForAtom03 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS090 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS091Netscape \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS091Userland \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS092 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS093 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS094 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS10 \
+ com.sun.syndication.feed.synd.impl.ConverterForRSS20
Modified: labs/shotoku/trunk/shotoku-example/shotoku-example.iml
===================================================================
--- labs/shotoku/trunk/shotoku-example/shotoku-example.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-example/shotoku-example.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-example/src/java/org/jboss/shotoku/example/ExampleEmbedded.java
===================================================================
--- labs/shotoku/trunk/shotoku-example/src/java/org/jboss/shotoku/example/ExampleEmbedded.java 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-example/src/java/org/jboss/shotoku/example/ExampleEmbedded.java 2006-10-03 22:06:31 UTC (rev 6563)
@@ -17,7 +17,8 @@
/**
* @author Adam Warski (adamw at aster.pl)
*/
-public class ExampleEmbedded {private ContentManager cm;
+public class ExampleEmbedded {
+ private ContentManager cm;
private Set<Node> openNodes;
private Set<Directory> openDirectories;
@@ -184,8 +185,9 @@
}
public static void main(String[] argv) throws IOException {
- System.out.println("Welcome to Shotoku example!");
+ /*System.out.println("Welcome to Shotoku example!");
+
ExampleEmbedded ee = new ExampleEmbedded();
while (true) {
@@ -268,6 +270,6 @@
System.out.println("Exception " + e.getClass().getName() +
" caught, message: " + e.getMessage() + ".");
}
- }
+ } */
}
}
Modified: labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-file-access/shotoku-file-access.iml
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/shotoku-file-access.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-file-access/shotoku-file-access.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-files/shotoku-files.iml
===================================================================
--- labs/shotoku/trunk/shotoku-files/shotoku-files.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-files/shotoku-files.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-jcr/shotoku-jcr.iml
===================================================================
--- labs/shotoku/trunk/shotoku-jcr/shotoku-jcr.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-jcr/shotoku-jcr.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-portal/shotoku-portal.iml
===================================================================
--- labs/shotoku/trunk/shotoku-portal/shotoku-portal.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-portal/shotoku-portal.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-svn/shotoku-svn.iml
===================================================================
--- labs/shotoku/trunk/shotoku-svn/shotoku-svn.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-svn/shotoku-svn.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml
===================================================================
--- labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-tags/shotoku-tags.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-test/shotoku-test.iml
===================================================================
--- labs/shotoku/trunk/shotoku-test/shotoku-test.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-test/shotoku-test.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-user/shotoku-user.iml
===================================================================
--- labs/shotoku/trunk/shotoku-user/shotoku-user.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-user/shotoku-user.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku-web/shotoku-web.iml
===================================================================
--- labs/shotoku/trunk/shotoku-web/shotoku-web.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku-web/shotoku-web.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target" />
<exclude-output />
<content url="file://$MODULE_DIR$">
Modified: labs/shotoku/trunk/shotoku.iml
===================================================================
--- labs/shotoku/trunk/shotoku.iml 2006-10-03 22:00:42 UTC (rev 6562)
+++ labs/shotoku/trunk/shotoku.iml 2006-10-03 22:06:31 UTC (rev 6563)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4" relativePaths="true" type="JAVA_MODULE">
<component name="ModuleRootManager" />
- <component name="NewModuleRootManager">
+ <component name="NewModuleRootManager" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
More information about the jboss-svn-commits
mailing list