org.blojsom.fetcher
Interface Fetcher

All Known Implementing Classes:
DatabaseFetcher

public interface Fetcher

Fetcher

Since:
blojsom 3.0
Version:
$Id: Fetcher.java,v 1.22 2007/04/03 16:40:59 czarneckid Exp $
Author:
David Czarnecki

Method Summary
 java.lang.Integer countEntries(Blog blog)
          Count the number of entries for a blog
 java.lang.Integer countEntriesForCategory(Blog blog, Category category)
          Count the number of entries for a blog category
 void deleteBlog(Blog blog)
          Delete a blog
 void deleteCategory(Blog blog, Category category)
          Delete a given Category
 void deleteComment(Blog blog, Comment comment)
          Delete a given Comment
 void deleteEntry(Blog blog, Entry entry)
          Delete a given Entry
 void deletePingback(Blog blog, Pingback pingback)
          Delete a given Pingback
 void deleteTrackback(Blog blog, Trackback trackback)
          Delete a given Trackback
 void deleteUser(Blog blog, java.lang.Integer userID)
          Delete a given user from a blog
 void destroy()
          Called when BlojsomServlet is taken out of service
 Category[] fetchCategories(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.lang.String flavor, java.util.Map context)
          Fetch a set of Category objects
 Entry[] fetchEntries(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.lang.String flavor, java.util.Map context)
          Fetch a set of Entry objects.
 Entry[] findEntries(Blog blog, java.lang.String query)
          Find entries which have the search query in their title or description
 Entry[] findEntriesBetweenDates(Blog blog, java.util.Date startDate, java.util.Date endDate)
          Find entries between a start and end date
 Entry[] findEntriesByMetadataKeyValue(Blog blog, java.lang.String metadataKey, java.lang.String metadataValue, boolean pre, boolean post)
          Find entries by a metadata key/value pair
 Entry[] findEntriesWithMetadataKey(Blog blog, java.lang.String metadataKey)
          Find entries with a given metadata key
 java.util.List findResponsesByQuery(Blog blog, java.lang.String query)
          Find the responses (comments, trackbacks, pingbacks) for a given Blog matching some query
 java.util.List findResponsesByStatus(Blog blog, java.lang.String[] status)
          Find the responses (comments, trackbacks, pingbacks) for a given Blog matching one of a set of status codes
 User[] getUsers(Blog blog)
          Retrieve the users for a given blog
 void init()
          Initialize this fetcher.
 Category[] loadAllCategories(Blog blog)
          Load each Category for a given blog
 Entry[] loadAllEntriesForCategory(Blog blog, java.lang.Integer categoryId)
          Load all the entries for a given category
 Blog loadBlog(java.lang.Integer id)
          Load the Blog given the ID
 Blog loadBlog(java.lang.String blogId)
          Load the Blog given the blog ID
 java.lang.String[] loadBlogIDs()
          Load the blog IDs
 void loadCategory(Blog blog, Category category)
          Load a given Category
 Category loadCategory(Blog blog, java.lang.Integer categoryId)
          Load the Category for a given category ID
 Category loadCategory(Blog blog, java.lang.String name)
          Load the Category for a given category name
 void loadComment(Blog blog, Comment comment)
          Load a given Comment
 Entry[] loadEntries(Blog blog, int pageSize, int page)
          Load a set of entries using a given page size and page in which to retrieve the entries
 Entry[] loadEntries(int pageSize, int page, Category specificCategory, Category[] defaultCategories)
          Load a set of entries using a given page size and page in which to retrieve the entries
 Entry[] loadEntriesForCategory(Blog blog, java.lang.Integer categoryId, java.lang.Integer limit)
          Load all the entries for a given category
 void loadEntry(Blog blog, Entry entry)
          Load a given Entry
 Entry loadEntry(Blog blog, java.lang.Integer entryId)
          Load an Entry for a given entry ID
 Entry loadEntry(Blog blog, java.lang.String postSlug)
          Load an Entry given a post slug
 void loadPingback(Blog blog, Pingback pingback)
          Load a given Pingback
 Pingback loadPingback(Blog blog, java.lang.String sourceURI, java.lang.String targetURI)
          Load a pingback given the source URI and target URI
 Entry[] loadPreviousEntries(Blog blog, Entry entry, int numPreviousEntries)
          Loads the previous entries of a specified entry
 java.util.List loadRecentComments(Blog blog)
          Load the recent comments for a blog
 java.util.List loadRecentPingbacks(Blog blog)
          Load the recent pingbacks for a blog
 java.util.List loadRecentTrackbacks(Blog blog)
          Load the recent trackbacks for a blog
 void loadTrackback(Blog blog, Trackback trackback)
          Load a given Trackback
 User loadUser(Blog blog, java.lang.Integer userID)
          Load a given User from a blog given their ID
 User loadUser(Blog blog, java.lang.String userLogin)
          Load a User from a blog
 Blog newBlog()
          Return a new Blog instance
 Category newCategory()
          Return a new Category instance
 Comment newComment()
          Return a new Comment instance
 Entry newEntry()
          Return a new Entry instance
 Pingback newPingback()
          Return a new Pingback instance
 Trackback newTrackback()
          Return a new Trackback instance
 User newUser()
          Return a new User instance
 void saveBlog(Blog blog)
          Save a Blog
 void saveCategory(Blog blog, Category category)
          Save a given Category
 void saveComment(Blog blog, Comment comment)
          Save a given Comment
 void saveEntry(Blog blog, Entry entry)
          Save a given Entry
 void savePingback(Blog blog, Pingback pingback)
          Save a given Pingback
 void saveTrackback(Blog blog, Trackback trackback)
          Save a given Trackback
 User saveUser(Blog blog, User user)
          Save a given User to the blog
 

Method Detail

init

public void init()
          throws FetcherException
Initialize this fetcher. This method only called when the fetcher is instantiated.

Throws:
FetcherException - If there is an error initializing the fetcher

newEntry

public Entry newEntry()
Return a new Entry instance

Returns:
Blog entry instance

newComment

public Comment newComment()
Return a new Comment instance

Returns:
Comment comment

newTrackback

public Trackback newTrackback()
Return a new Trackback instance

Returns:
Trackback trackback

newPingback

public Pingback newPingback()
Return a new Pingback instance

Returns:
Pingback pingback

newCategory

public Category newCategory()
Return a new Category instance

Returns:
Category category

newBlog

public Blog newBlog()
Return a new Blog instance

Returns:
Blog blog

newUser

public User newUser()
Return a new User instance

Returns:
User user

loadBlogIDs

public java.lang.String[] loadBlogIDs()
                               throws FetcherException
Load the blog IDs

Returns:
List of blog IDs
Throws:
FetcherException - If there is an error loading the blog IDs

loadBlog

public Blog loadBlog(java.lang.String blogId)
              throws FetcherException
Load the Blog given the blog ID

Parameters:
blogId - Blog ID
Returns:
Blog blog
Throws:
FetcherException - If there is an error loading the blog

loadBlog

public Blog loadBlog(java.lang.Integer id)
              throws FetcherException
Load the Blog given the ID

Parameters:
id - ID
Returns:
Blog blog
Throws:
FetcherException - If there is an error loading the blog

saveBlog

public void saveBlog(Blog blog)
              throws FetcherException
Save a Blog

Parameters:
blog - Blog
Throws:
FetcherException - If there is an error saving the blog

deleteBlog

public void deleteBlog(Blog blog)
                throws FetcherException
Delete a blog

Parameters:
blog - Blog
Throws:
FetcherException - If there is an error deleting the blog

fetchEntries

public Entry[] fetchEntries(javax.servlet.http.HttpServletRequest httpServletRequest,
                            javax.servlet.http.HttpServletResponse httpServletResponse,
                            Blog blog,
                            java.lang.String flavor,
                            java.util.Map context)
                     throws FetcherException
Fetch a set of Entry objects.

Parameters:
httpServletRequest - Request
httpServletResponse - Response
blog - Blog instance
flavor - Flavor
context - Context
Returns:
Blog entries retrieved for the particular request
Throws:
FetcherException - If there is an error retrieving the blog entries for the request

loadAllEntriesForCategory

public Entry[] loadAllEntriesForCategory(Blog blog,
                                         java.lang.Integer categoryId)
                                  throws FetcherException
Load all the entries for a given category

Parameters:
blog - Blog
categoryId - Category ID
Returns:
Blog entries for a given category
Throws:
FetcherException - If there is an error loading the entries

loadEntriesForCategory

public Entry[] loadEntriesForCategory(Blog blog,
                                      java.lang.Integer categoryId,
                                      java.lang.Integer limit)
                               throws FetcherException
Load all the entries for a given category

Parameters:
blog - Blog
categoryId - Category ID
limit - Limit on number of entries to return
Returns:
Blog entries for a given category
Throws:
FetcherException - If there is an error loading the entries

loadEntries

public Entry[] loadEntries(Blog blog,
                           int pageSize,
                           int page)
                    throws FetcherException
Load a set of entries using a given page size and page in which to retrieve the entries

Parameters:
blog - Blog
pageSize - Page size
page - Page
Returns:
Blog entries
Throws:
FetcherException - If there is an error loading the entries

loadEntries

public Entry[] loadEntries(int pageSize,
                           int page,
                           Category specificCategory,
                           Category[] defaultCategories)
                    throws FetcherException
Load a set of entries using a given page size and page in which to retrieve the entries

Parameters:
pageSize - Page size
page - Page
specificCategory - Category
defaultCategories - Default categories to use for requesting entries from the blogs
Returns:
Blog entries
Throws:
FetcherException - If there is an error loading the entries

findEntries

public Entry[] findEntries(Blog blog,
                           java.lang.String query)
                    throws FetcherException
Find entries which have the search query in their title or description

Parameters:
blog - Blog
query - Search query
Returns:
Blog entries which have the search query in their title or descirption
Throws:
FetcherException - If there is an error searching through entries

findEntriesByMetadataKeyValue

public Entry[] findEntriesByMetadataKeyValue(Blog blog,
                                             java.lang.String metadataKey,
                                             java.lang.String metadataValue,
                                             boolean pre,
                                             boolean post)
                                      throws FetcherException
Find entries by a metadata key/value pair

Parameters:
blog - Blog
metadataKey - Metadata key
metadataValue - Metadata value
pre - If the search should use % before the metadata value (match anything before)
post - If the search should use % after the metadata value (match antthing after)
Returns:
Entries matching metadata key and value using LIKE syntax for metadata value
Throws:
FetcherException - If there is an error searching through entries

findEntriesWithMetadataKey

public Entry[] findEntriesWithMetadataKey(Blog blog,
                                          java.lang.String metadataKey)
                                   throws FetcherException
Find entries with a given metadata key

Parameters:
blog - Blog
metadataKey - Metadata key
Returns:
Entries with the given metadata key
Throws:
FetcherException - If there is an error searching through entries

findEntriesBetweenDates

public Entry[] findEntriesBetweenDates(Blog blog,
                                       java.util.Date startDate,
                                       java.util.Date endDate)
                                throws FetcherException
Find entries between a start and end date

Parameters:
blog - Blog
startDate - Start date
endDate - End date
Returns:
Entries between a start and end date
Throws:
FetcherException - If there is an error searching for entries between the dates

loadPreviousEntries

public Entry[] loadPreviousEntries(Blog blog,
                                   Entry entry,
                                   int numPreviousEntries)
                            throws FetcherException
Loads the previous entries of a specified entry

Parameters:
blog - Blog
entry - Entry
numPreviousEntries - Number of previous entries to retrieve
Returns:
Array of entries before the given entry
Throws:
FetcherException - If there is an error retrieving previous entries

countEntries

public java.lang.Integer countEntries(Blog blog)
                               throws FetcherException
Count the number of entries for a blog

Parameters:
blog - Blog
Returns:
Number of entries
Throws:
FetcherException - If there is an error counting the blog entries

countEntriesForCategory

public java.lang.Integer countEntriesForCategory(Blog blog,
                                                 Category category)
                                          throws FetcherException
Count the number of entries for a blog category

Parameters:
blog - Blog
category - Category
Returns:
Number of entries
Throws:
FetcherException - If there is an error counting the blog entries in the category

loadEntry

public Entry loadEntry(Blog blog,
                       java.lang.Integer entryId)
                throws FetcherException
Load an Entry for a given entry ID

Parameters:
blog - Blog
entryId - Entry ID
Returns:
Entry entry
Throws:
FetcherException - If there is an error loading the entry

loadEntry

public Entry loadEntry(Blog blog,
                       java.lang.String postSlug)
                throws FetcherException
Load an Entry given a post slug

Parameters:
blog - Blog
postSlug - Post slug
Returns:
Entry for the given post slug
Throws:
FetcherException - If an entry for the blog and post slug cannot be found

fetchCategories

public Category[] fetchCategories(javax.servlet.http.HttpServletRequest httpServletRequest,
                                  javax.servlet.http.HttpServletResponse httpServletResponse,
                                  Blog blog,
                                  java.lang.String flavor,
                                  java.util.Map context)
                           throws FetcherException
Fetch a set of Category objects

Parameters:
httpServletRequest - Request
httpServletResponse - Response
blog - Blog instance
flavor - Flavor
context - Context
Returns:
Blog categories retrieved for the particular request
Throws:
FetcherException - If there is an error retrieving the blog categories for the request

loadAllCategories

public Category[] loadAllCategories(Blog blog)
                             throws FetcherException
Load each Category for a given blog

Parameters:
blog - Blog
Returns:
Category list for the blog
Throws:
FetcherException - If there is an error loading the categories

loadCategory

public Category loadCategory(Blog blog,
                             java.lang.Integer categoryId)
                      throws FetcherException
Load the Category for a given category ID

Parameters:
blog - Blog
categoryId - Category ID
Returns:
Category for the given category ID
Throws:
FetcherException - If there is an error loading the category

loadCategory

public Category loadCategory(Blog blog,
                             java.lang.String name)
                      throws FetcherException
Load the Category for a given category name

Parameters:
blog - Blog
name - Category name
Returns:
Category for the given category name
Throws:
FetcherException - If there is an error loading the category

saveEntry

public void saveEntry(Blog blog,
                      Entry entry)
               throws FetcherException
Save a given Entry

Parameters:
blog - Blog
entry - Entry to save
Throws:
FetcherException - If there is an error saving the entry

loadEntry

public void loadEntry(Blog blog,
                      Entry entry)
               throws FetcherException
Load a given Entry

Parameters:
blog - Blog
entry - Entry to load
Throws:
FetcherException - If there is an error loading the entry

deleteEntry

public void deleteEntry(Blog blog,
                        Entry entry)
                 throws FetcherException
Delete a given Entry

Parameters:
blog - Blog
entry - Entry to delete
Throws:
FetcherException - If there is an error deleting the entry

saveCategory

public void saveCategory(Blog blog,
                         Category category)
                  throws FetcherException
Save a given Category

Parameters:
blog - Blog
category - Category to save
Throws:
FetcherException - If there is an error saving the category

loadCategory

public void loadCategory(Blog blog,
                         Category category)
                  throws FetcherException
Load a given Category

Parameters:
blog - Blog
category - Category to load
Throws:
FetcherException - If there is an loading saving the category

deleteCategory

public void deleteCategory(Blog blog,
                           Category category)
                    throws FetcherException
Delete a given Category

Parameters:
blog - Blog
category - Category to delete
Throws:
FetcherException - If there is an error deleting the category

saveComment

public void saveComment(Blog blog,
                        Comment comment)
                 throws FetcherException
Save a given Comment

Parameters:
blog - Blog
comment - Comment to save
Throws:
FetcherException - If there is an error saving the comment

loadComment

public void loadComment(Blog blog,
                        Comment comment)
                 throws FetcherException
Load a given Comment

Parameters:
blog - Blog
comment - Comment to load
Throws:
FetcherException - If there is an error loading the comment

deleteComment

public void deleteComment(Blog blog,
                          Comment comment)
                   throws FetcherException
Delete a given Comment

Parameters:
blog - Blog
comment - Comment to delete
Throws:
FetcherException - If there is an error deleting the comment

loadRecentComments

public java.util.List loadRecentComments(Blog blog)
                                  throws FetcherException
Load the recent comments for a blog

Parameters:
blog - Blog
Returns:
List of recent comment
Throws:
FetcherException - If there is an error retrieving the recent comments

saveTrackback

public void saveTrackback(Blog blog,
                          Trackback trackback)
                   throws FetcherException
Save a given Trackback

Parameters:
blog - Blog
trackback - Trackback to save
Throws:
FetcherException - If there is an error saving the trackback

loadTrackback

public void loadTrackback(Blog blog,
                          Trackback trackback)
                   throws FetcherException
Load a given Trackback

Parameters:
blog - Blog
trackback - Trackback to load
Throws:
FetcherException - If there is an error loading the trackback

deleteTrackback

public void deleteTrackback(Blog blog,
                            Trackback trackback)
                     throws FetcherException
Delete a given Trackback

Parameters:
blog - Blog
trackback - Trackback to delete
Throws:
FetcherException - If there is an error deleting the trackback

loadRecentTrackbacks

public java.util.List loadRecentTrackbacks(Blog blog)
                                    throws FetcherException
Load the recent trackbacks for a blog

Parameters:
blog - Blog
Returns:
List of recent trackbacks
Throws:
FetcherException - If there is an error retrieving the recent trackbacks

savePingback

public void savePingback(Blog blog,
                         Pingback pingback)
                  throws FetcherException
Save a given Pingback

Parameters:
blog - Blog
pingback - Pingback to save
Throws:
FetcherException - If there is an error saving the pingback

loadPingback

public void loadPingback(Blog blog,
                         Pingback pingback)
                  throws FetcherException
Load a given Pingback

Parameters:
blog - Blog
pingback - Pingback to load
Throws:
FetcherException - If there is an error loading the pingback

loadPingback

public Pingback loadPingback(Blog blog,
                             java.lang.String sourceURI,
                             java.lang.String targetURI)
                      throws FetcherException
Load a pingback given the source URI and target URI

Parameters:
blog - Blog
sourceURI - Source URI
targetURI - Target URI
Returns:
Pingback given the source and target URIs or null if not found
Throws:
FetcherException - If there was an erorr loading the pingback

deletePingback

public void deletePingback(Blog blog,
                           Pingback pingback)
                    throws FetcherException
Delete a given Pingback

Parameters:
blog - Blog
pingback - Pingback to delete
Throws:
FetcherException - If there is an error deleting the pingback

loadRecentPingbacks

public java.util.List loadRecentPingbacks(Blog blog)
                                   throws FetcherException
Load the recent pingbacks for a blog

Parameters:
blog - Blog
Returns:
List of recent pingbacks
Throws:
FetcherException - If there is an error retrieving the recent pingbacks

getUsers

public User[] getUsers(Blog blog)
Retrieve the users for a given blog

Parameters:
blog - Blog
Returns:
List of Users for a blog

loadUser

public User loadUser(Blog blog,
                     java.lang.String userLogin)
              throws FetcherException
Load a User from a blog

Parameters:
blog - Blog
userLogin - Login ID
Returns:
User user
Throws:
FetcherException - If there is an error loading the User from the blog

loadUser

public User loadUser(Blog blog,
                     java.lang.Integer userID)
              throws FetcherException
Load a given User from a blog given their ID

Parameters:
blog - Blog
userID - User ID
Returns:
User user
Throws:
FetcherException - If there is an error loading the user

saveUser

public User saveUser(Blog blog,
                     User user)
              throws FetcherException
Save a given User to the blog

Parameters:
blog - Blog
user - User
Returns:
User user
Throws:
FetcherException - If there is an error saving the user to the blog

deleteUser

public void deleteUser(Blog blog,
                       java.lang.Integer userID)
                throws FetcherException
Delete a given user from a blog

Parameters:
blog - Blog
userID - User ID
Throws:
FetcherException - If there is an error deleting the user from the blog

findResponsesByStatus

public java.util.List findResponsesByStatus(Blog blog,
                                            java.lang.String[] status)
                                     throws FetcherException
Find the responses (comments, trackbacks, pingbacks) for a given Blog matching one of a set of status codes

Parameters:
blog - Blog
status - List of status codes to search
Returns:
List of responses (comments, trackbacks, pingbacks) matching one of a set of status codes
Throws:
FetcherException - If there is an error loading the responses

findResponsesByQuery

public java.util.List findResponsesByQuery(Blog blog,
                                           java.lang.String query)
                                    throws FetcherException
Find the responses (comments, trackbacks, pingbacks) for a given Blog matching some query

Parameters:
blog - Blog
query - Query which will match on various items such as commenter name, e-mail, IP address, etc.
Returns:
List of responses (comments, trackbacks, pingbacks) matching query
Throws:
FetcherException - If there is an error loading the responses

destroy

public void destroy()
             throws FetcherException
Called when BlojsomServlet is taken out of service

Throws:
FetcherException - If there is an error in finalizing this fetcher