incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r999981 - /incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java
Date Wed, 22 Sep 2010 14:34:49 GMT
Author: jbohn
Date: Wed Sep 22 14:34:49 2010
New Revision: 999981

URL: http://svn.apache.org/viewvc?rev=999981&view=rev
Log:
ARIES-411 fix Blog NPE when comment service isn't available - patch by Emily Jiang - also
reformatted code to remove tabs

Modified:
    incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java

Modified: incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java?rev=999981&r1=999980&r2=999981&view=diff
==============================================================================
--- incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java
(original)
+++ incubator/aries/trunk/samples/blog/blog-biz/src/main/java/org/apache/aries/samples/blog/biz/BloggingServiceImpl.java
Wed Sep 22 14:34:49 2010
@@ -20,6 +20,7 @@ package org.apache.aries.samples.blog.bi
 
 import java.text.ParseException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.aries.samples.blog.api.BlogAuthor;
@@ -32,96 +33,108 @@ import org.apache.aries.samples.blog.api
 
 /** Implementation of the BloggingService */
 public class BloggingServiceImpl implements BloggingService {
-	private BlogEntryManager blogEntryManager;
-	private BlogAuthorManager blogAuthorManager;
-	private BlogCommentManager blogCommentManager;
-
-	// Injected via blueprint
-	public void setBlogEntryManager(BlogEntryManager blogPostManager) {
-		this.blogEntryManager = blogPostManager;
-	}
-
-	// Injected via blueprint
-	public void setBlogAuthorManager(BlogAuthorManager authorManager) {
-		this.blogAuthorManager = authorManager;
-	}
-	
-	// Injected via blueprint
-	public void setBlogCommentManager(BlogCommentManager commentManager) {
-		this.blogCommentManager = commentManager;
-	}
-
-
-	public String getBlogTitle() {
-		return new BlogImpl().getBlogTitle();
-	}
-
-	public BlogAuthor getBlogAuthor(String email) {
-		return blogAuthorManager.getAuthor(email);
-	}
-
-	public void createBlogAuthor(String email, String nickName, String name,
-			String bio, String dob) {
-		try {
-			blogAuthorManager.createAuthor(email, dob, name, nickName, bio);
-		} catch (ParseException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
-	public void updateBlogAuthor(String email, String nickName, String name,
-			String bio, String dob) {
-		try {
-			blogAuthorManager.updateAuthor(email, dob, name, nickName, bio);
-		} catch (ParseException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
-
-	public BlogEntry getPost(long id) {
-		return blogEntryManager.getBlogPost(id);
-	}
-
-	public List<? extends BlogEntry> getBlogEntries(int firstPostIndex,
-			int noOfPosts) {
-		return blogEntryManager.getBlogEntries(firstPostIndex, noOfPosts);
-
-	}
-
-	public List<? extends BlogEntry> getAllBlogEntries() {
-		return blogEntryManager.getAllBlogEntries();
-	}
-
-	public int getNoOfEntries() {
-		return blogEntryManager.getNoOfPosts();
-	}
-
-	public void createBlogEntry(String email, String title, String blogText,
-			String tags) {
-		blogEntryManager.createBlogPost(email, title, blogText, Arrays
-				.asList(tags.split(",")));
-	}
-
-	public void createBlogComment(String comment, String authorEmail, long id) {
-		blogCommentManager.createComment(comment, authorEmail, id);
-	}
-
-	public void deleteBlogComment(BlogComment comment) {
-		blogCommentManager.deleteComment(comment.getId());
-	}
-
-	public List<? extends BlogComment> getCommentsForEntry(BlogEntry entry) {
-		return blogCommentManager.getCommentsForPost(entry.getId());
-	}
-
-	public BlogEntry getBlogEntry(long id) {
-		return blogEntryManager.getBlogPost(id);
-	}
-	
-	public boolean isCommentingAvailable() {
-		return blogCommentManager.isCommentingAvailable();
+    private BlogEntryManager blogEntryManager;
+    private BlogAuthorManager blogAuthorManager;
+    private BlogCommentManager blogCommentManager;
+
+    // Injected via blueprint
+    public void setBlogEntryManager(BlogEntryManager blogPostManager) {
+        this.blogEntryManager = blogPostManager;
+    }
+
+    // Injected via blueprint
+    public void setBlogAuthorManager(BlogAuthorManager authorManager) {
+        this.blogAuthorManager = authorManager;
+    }
+
+    // Injected via blueprint
+    public void setBlogCommentManager(BlogCommentManager commentManager) {
+        this.blogCommentManager = commentManager;
+    }
+
+
+    public String getBlogTitle() {
+        return new BlogImpl().getBlogTitle();
+    }
+
+    public BlogAuthor getBlogAuthor(String email) {
+        return blogAuthorManager.getAuthor(email);
+    }
+
+    public void createBlogAuthor(String email, String nickName, String name,
+                                 String bio, String dob) {
+        try {
+            blogAuthorManager.createAuthor(email, dob, name, nickName, bio);
+        }
+        catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    public void updateBlogAuthor(String email, String nickName, String name,
+                                 String bio, String dob) {
+        try {
+            blogAuthorManager.updateAuthor(email, dob, name, nickName, bio);
+        }
+        catch (ParseException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+    }
+
+    public BlogEntry getPost(long id) {
+        return blogEntryManager.getBlogPost(id);
+    }
+
+    public List<? extends BlogEntry> getBlogEntries(int firstPostIndex,
+                                                    int noOfPosts) {
+        return blogEntryManager.getBlogEntries(firstPostIndex, noOfPosts);
+
+    }
+
+    public List<? extends BlogEntry> getAllBlogEntries() {
+        return blogEntryManager.getAllBlogEntries();
+    }
+
+    public int getNoOfEntries() {
+        return blogEntryManager.getNoOfPosts();
+    }
+
+    public void createBlogEntry(String email, String title, String blogText,
+                                String tags) {
+        blogEntryManager.createBlogPost(email, title, blogText, Arrays
+                                        .asList(tags.split(",")));
+    }
+
+    public void createBlogComment(String comment, String authorEmail, long id) {
+        if (blogCommentManager != null) {
+            blogCommentManager.createComment(comment, authorEmail, id);
+        }
+    }
+
+    public void deleteBlogComment(BlogComment comment) {
+        if (blogCommentManager != null) {
+            blogCommentManager.deleteComment(comment.getId());
+        }
+    }
+
+    public List<? extends BlogComment> getCommentsForEntry(BlogEntry entry) {
+        if (blogCommentManager != null) {
+            return blogCommentManager.getCommentsForPost(entry.getId());
+        }
+        return Collections.<BlogComment>emptyList();
+    }
+
+    public BlogEntry getBlogEntry(long id) {
+        return blogEntryManager.getBlogPost(id);
+    }
+
+    public boolean isCommentingAvailable() {
+        if (blogCommentManager != null) {
+            return blogCommentManager.isCommentingAvailable();
+        }
+        return false;
 
-	}
+    }
 }
\ No newline at end of file



Mime
View raw message