[jboss-svn-commits] JBL Code SVN: r6539 - in labs/shotoku/trunk/shotoku-blog: . src/java/org/jboss/blog/model src/java/org/jboss/blog/service/name

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 2 17:48:21 EDT 2006


Author: adamw
Date: 2006-10-02 17:48:17 -0400 (Mon, 02 Oct 2006)
New Revision: 6539

Added:
   labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java
   labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntry.java
   labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntryDoesNotExistException.java
Removed:
   labs/shotoku/trunk/shotoku-blog/blog.iml
Modified:
   labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java
Log:
http://jira.jboss.com/jira/browse/JBSHOTOKU-94

Deleted: labs/shotoku/trunk/shotoku-blog/blog.iml
===================================================================
--- labs/shotoku/trunk/shotoku-blog/blog.iml	2006-10-02 21:37:25 UTC (rev 6538)
+++ labs/shotoku/trunk/shotoku-blog/blog.iml	2006-10-02 21:48:17 UTC (rev 6539)
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module version="4" relativePaths="true" type="JAVA_MODULE">
-  <component name="ModuleRootManager" />
-  <component name="NewModuleRootManager">
-    <output url="file://$MODULE_DIR$/target" />
-    <exclude-output />
-    <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
-    </content>
-    <orderEntry type="inheritedJdk" />
-    <orderEntry type="sourceFolder" forTests="false" />
-    <orderEntryProperties />
-  </component>
-</module>
-

Added: 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:37:25 UTC (rev 6538)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntries.java	2006-10-02 21:48:17 UTC (rev 6539)
@@ -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 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));
+    }
+}

Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntry.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntry.java	2006-10-02 21:37:25 UTC (rev 6538)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntry.java	2006-10-02 21:48:17 UTC (rev 6539)
@@ -0,0 +1,74 @@
+package org.jboss.blog.model;
+
+import java.util.Date;
+import java.util.Locale;
+import java.text.DateFormat;
+
+/**
+ * A class representing a single blog entry.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class BlogEntry {
+    private String author;
+    private String title;
+    private String description;
+    private Date created;
+    private String link;
+    private String guid;
+
+    /**
+     * This should be an URL to a feed with comments to this item. If no
+     * comments are available, this should be null.
+     */
+    private String commentLink;
+
+    public BlogEntry(String author, String title, String description,
+                     Date created, String link, String guid,
+                     String commentLink) {
+        this.author = author;
+        this.title = title;
+        this.description = description;
+        this.created = created;
+        this.link = link;
+        this.guid = guid;
+        this.commentLink = commentLink;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public Date getCreated() {
+        return created;
+    }
+
+    public String getCreatedDate() {
+        return DateFormat.getDateInstance(DateFormat.FULL,
+                Locale.getDefault()).format(created);
+    }
+
+    public String getCreatedTime() {
+        return DateFormat.getTimeInstance(DateFormat.SHORT,
+                Locale.getDefault()).format(created);
+    }
+
+    public String getLink() {
+        return link;
+    }
+
+    public String getGuid() {
+        return guid;
+    }
+
+    public String getCommentLink() {
+        return commentLink;
+    }
+}

Added: labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntryDoesNotExistException.java
===================================================================
--- labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntryDoesNotExistException.java	2006-10-02 21:37:25 UTC (rev 6538)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/model/BlogEntryDoesNotExistException.java	2006-10-02 21:48:17 UTC (rev 6539)
@@ -0,0 +1,22 @@
+package org.jboss.blog.model;
+
+/**
+ * An exception thrown when a blog entry is demanded which does not exist.
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class BlogEntryDoesNotExistException extends Exception {
+    public BlogEntryDoesNotExistException() {
+    }
+
+    public BlogEntryDoesNotExistException(String message) {
+        super(message);
+    }
+
+    public BlogEntryDoesNotExistException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public BlogEntryDoesNotExistException(Throwable cause) {
+        super(cause);
+    }
+}

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-02 21:37:25 UTC (rev 6538)
+++ labs/shotoku/trunk/shotoku-blog/src/java/org/jboss/blog/service/name/PortletPreferencesBlogNameService.java	2006-10-02 21:48:17 UTC (rev 6539)
@@ -32,8 +32,13 @@
      * given initial parameter.
      */
     private String getPreference(PortletRequest req, String prefName, String initParamName) {
-        return req.getPreferences().getValue(prefName,
-                req.getPortletSession().getPortletContext().getInitParameter(initParamName));
+        String pref = req.getPreferences().getValue(prefName, null);
+
+        if (pref == null) {
+            pref = req.getPortletSession().getPortletContext().getInitParameter(initParamName);
+        }
+
+        return pref;
     }
 
     public BlogName getBlogName(Object request) {




More information about the jboss-svn-commits mailing list