|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.blojsom.fetcher.database.DatabaseFetcher
Database fetcher
Field Summary | |
protected java.util.Properties |
_blojsomProperties
|
protected EventBroadcaster |
_eventBroadcaster
|
protected org.apache.commons.logging.Log |
_logger
|
protected javax.servlet.ServletConfig |
_servletConfig
|
protected org.hibernate.SessionFactory |
_sessionFactory
|
Constructor Summary | |
DatabaseFetcher()
Create a new instance of the database fetcher |
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 |
protected java.lang.String |
createPostSlug(Blog blog,
Entry entry)
Create a unique post slug |
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)
Load the responses (comments, trackbacks, pingbacks) for a given Blog matching one of a set of status codes |
protected java.lang.String |
getBlogCategory(Blog blog,
javax.servlet.http.HttpServletRequest httpServletRequest)
Determine the blog category based on the request |
User[] |
getUsers(Blog blog)
Retrieve the users for a given blog |
void |
handleEvent(Event event)
Handle an event broadcast from another component |
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 |
processEvent(Event event)
Process an event from another component |
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 |
void |
setBlojsomProperties(java.util.Properties blojsomProperties)
Set the default blojsom properties |
void |
setEventBroadcaster(EventBroadcaster eventBroadcaster)
Set the EventBroadcaster event broadcaster |
void |
setServletConfig(javax.servlet.ServletConfig servletConfig)
Set the ServletConfig for the fetcher to grab initialization parameters |
void |
setSessionFactory(org.hibernate.SessionFactory sessionFactory)
Set the SessionFactory |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.apache.commons.logging.Log _logger
protected javax.servlet.ServletConfig _servletConfig
protected EventBroadcaster _eventBroadcaster
protected org.hibernate.SessionFactory _sessionFactory
protected java.util.Properties _blojsomProperties
Constructor Detail |
public DatabaseFetcher()
Method Detail |
public void setServletConfig(javax.servlet.ServletConfig servletConfig)
ServletConfig
for the fetcher to grab initialization parameters
servletConfig
- ServletConfig
public void setEventBroadcaster(EventBroadcaster eventBroadcaster)
EventBroadcaster
event broadcaster
eventBroadcaster
- EventBroadcaster
public void setSessionFactory(org.hibernate.SessionFactory sessionFactory)
SessionFactory
sessionFactory
- SessionFactory
public void setBlojsomProperties(java.util.Properties blojsomProperties)
blojsomProperties
- Default blojsom propertiespublic void init() throws FetcherException
init
in interface Fetcher
FetcherException
- If there is an error initializing the fetcherpublic Entry newEntry()
Entry
instance
newEntry
in interface Fetcher
public Comment newComment()
Comment
instance
newComment
in interface Fetcher
Comment
objectpublic Trackback newTrackback()
Trackback
instance
newTrackback
in interface Fetcher
Trackback
objectpublic Pingback newPingback()
Pingback
instance
newPingback
in interface Fetcher
Pingback
objectpublic Category newCategory()
Category
instance
newCategory
in interface Fetcher
Category
objectpublic Blog newBlog()
Blog
instance
newBlog
in interface Fetcher
Blog
objectpublic User newUser()
User
instance
newUser
in interface Fetcher
User
objectpublic Blog loadBlog(java.lang.String blogId) throws FetcherException
Blog
given the blog ID
loadBlog
in interface Fetcher
blogId
- Blog ID
Blog
object
FetcherException
- If there is an error loading the blogpublic Blog loadBlog(java.lang.Integer id) throws FetcherException
Blog
given the ID
loadBlog
in interface Fetcher
id
- ID
Blog
blog
FetcherException
- If there is an error loading the blogpublic void saveBlog(Blog blog) throws FetcherException
Blog
saveBlog
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error saving the blogpublic void deleteBlog(Blog blog) throws FetcherException
deleteBlog
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error deleting the blogpublic java.lang.String[] loadBlogIDs() throws FetcherException
loadBlogIDs
in interface Fetcher
FetcherException
- If there is an error loading the blog IDspublic Entry[] fetchEntries(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.lang.String flavor, java.util.Map context) throws FetcherException
Entry
objects.
fetchEntries
in interface Fetcher
httpServletRequest
- RequesthttpServletResponse
- Responseblog
- Blog
instanceflavor
- Flavorcontext
- Context
FetcherException
- If there is an error retrieving the blog entries for the requestpublic Entry[] loadAllEntriesForCategory(Blog blog, java.lang.Integer categoryId) throws FetcherException
loadAllEntriesForCategory
in interface Fetcher
blog
- Blog
categoryId
- Category ID
FetcherException
- If there is an error loading the entriespublic Entry[] loadEntriesForCategory(Blog blog, java.lang.Integer categoryId, java.lang.Integer limit) throws FetcherException
loadEntriesForCategory
in interface Fetcher
blog
- Blog
categoryId
- Category IDlimit
- Limit on number of entries to return
FetcherException
- If there is an error loading the entriespublic Entry[] loadEntries(Blog blog, int pageSize, int page) throws FetcherException
loadEntries
in interface Fetcher
blog
- Blog
pageSize
- Page sizepage
- Page
FetcherException
- If there is an error loading the entriespublic Entry[] loadEntries(int pageSize, int page, Category specificCategory, Category[] defaultCategories) throws FetcherException
loadEntries
in interface Fetcher
pageSize
- Page sizepage
- PagespecificCategory
- CategorydefaultCategories
- Default categories to use for requesting entries from the blogs
FetcherException
- If there is an error loading the entriespublic Entry[] findEntries(Blog blog, java.lang.String query) throws FetcherException
findEntries
in interface Fetcher
blog
- Blog
query
- Search query
FetcherException
- If there is an error searching through entriespublic Entry[] findEntriesByMetadataKeyValue(Blog blog, java.lang.String metadataKey, java.lang.String metadataValue, boolean pre, boolean post) throws FetcherException
findEntriesByMetadataKeyValue
in interface Fetcher
blog
- Blog
metadataKey
- Metadata keymetadataValue
- Metadata valuepre
- 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)
FetcherException
- If there is an error searching through entriespublic Entry[] findEntriesWithMetadataKey(Blog blog, java.lang.String metadataKey) throws FetcherException
findEntriesWithMetadataKey
in interface Fetcher
blog
- Blog
metadataKey
- Metadata key
FetcherException
- If there is an error searching through entriespublic Entry[] findEntriesBetweenDates(Blog blog, java.util.Date startDate, java.util.Date endDate) throws FetcherException
findEntriesBetweenDates
in interface Fetcher
blog
- Blog
startDate
- Start dateendDate
- End date
FetcherException
- If there is an error searching for entries between the datespublic Entry[] loadPreviousEntries(Blog blog, Entry entry, int numPreviousEntries) throws FetcherException
loadPreviousEntries
in interface Fetcher
blog
- Blog
entry
- Entry
numPreviousEntries
- Number of previous entries to retrieve
FetcherException
- If there is an error retrieving previous entriespublic java.lang.Integer countEntries(Blog blog) throws FetcherException
countEntries
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error counting the blog entriespublic java.lang.Integer countEntriesForCategory(Blog blog, Category category) throws FetcherException
countEntriesForCategory
in interface Fetcher
blog
- Blog
category
- Category
FetcherException
- If there is an error counting the blog entries in the categorypublic Entry loadEntry(Blog blog, java.lang.Integer entryId) throws FetcherException
Entry
for a given entry ID
loadEntry
in interface Fetcher
blog
- Blog
entryId
- Entry ID
Entry
object
FetcherException
- If there is an error loading the entrypublic Entry loadEntry(Blog blog, java.lang.String postSlug) throws FetcherException
Entry
given a post slug
loadEntry
in interface Fetcher
blog
- Blog
postSlug
- Post slug
Entry
for the given post slug
FetcherException
- If an entry for the blog and post slug cannot be foundprotected java.lang.String getBlogCategory(Blog blog, javax.servlet.http.HttpServletRequest httpServletRequest)
blog
- Blog
httpServletRequest
- Request
Category
of the requested categorypublic Category[] fetchCategories(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse, Blog blog, java.lang.String flavor, java.util.Map context) throws FetcherException
Category
objects
fetchCategories
in interface Fetcher
httpServletRequest
- RequesthttpServletResponse
- Responseblog
- Blog
instanceflavor
- Flavorcontext
- Context
FetcherException
- If there is an error retrieving the blog categories for the requestpublic Category[] loadAllCategories(Blog blog) throws FetcherException
Category
for a given blog
loadAllCategories
in interface Fetcher
blog
- Blog
Category
list for the blog
FetcherException
- If there is an error loading the categoriespublic Category loadCategory(Blog blog, java.lang.Integer categoryId) throws FetcherException
Category
for a given category ID
loadCategory
in interface Fetcher
blog
- Blog
categoryId
- Category ID
Category
for the given category ID
FetcherException
- If there is an error loading the categorypublic Category loadCategory(Blog blog, java.lang.String name) throws FetcherException
Category
for a given category name
loadCategory
in interface Fetcher
blog
- Blog
name
- Category name
Category
for the given category name
FetcherException
- If there is an error loading the categoryprotected java.lang.String createPostSlug(Blog blog, Entry entry)
blog
- Blog
entry
- Entry
public void saveEntry(Blog blog, Entry entry) throws FetcherException
Entry
saveEntry
in interface Fetcher
blog
- Blog
entry
- Entry
to save
FetcherException
- If there is an error saving the entrypublic void loadEntry(Blog blog, Entry entry) throws FetcherException
Entry
loadEntry
in interface Fetcher
blog
- Blog
entry
- Entry
to load
FetcherException
- If there is an error loading the entrypublic void deleteEntry(Blog blog, Entry entry) throws FetcherException
Entry
deleteEntry
in interface Fetcher
blog
- Blog
entry
- Entry
to delete
FetcherException
- If there is an error deleting the entrypublic void saveCategory(Blog blog, Category category) throws FetcherException
Category
saveCategory
in interface Fetcher
blog
- Blog
category
- Category
to save
FetcherException
- If there is an error saving the categorypublic void loadCategory(Blog blog, Category category) throws FetcherException
Category
loadCategory
in interface Fetcher
blog
- Blog
category
- Category
to load
FetcherException
- If there is an loading saving the categorypublic void deleteCategory(Blog blog, Category category) throws FetcherException
Category
deleteCategory
in interface Fetcher
blog
- Blog
category
- Category
to delete
FetcherException
- If there is an error deleting the categorypublic void saveComment(Blog blog, Comment comment) throws FetcherException
Comment
saveComment
in interface Fetcher
blog
- Blog
comment
- Comment
to save
FetcherException
- If there is an error saving the commentpublic void loadComment(Blog blog, Comment comment) throws FetcherException
Comment
loadComment
in interface Fetcher
blog
- Blog
comment
- Comment
to load
FetcherException
- If there is an error loading the commentpublic void deleteComment(Blog blog, Comment comment) throws FetcherException
Comment
deleteComment
in interface Fetcher
blog
- Blog
comment
- Comment
to delete
FetcherException
- If there is an error deleting the commentpublic java.util.List loadRecentComments(Blog blog) throws FetcherException
loadRecentComments
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error retrieving the recent commentspublic void saveTrackback(Blog blog, Trackback trackback) throws FetcherException
Trackback
saveTrackback
in interface Fetcher
blog
- Blog
trackback
- Trackback
to save
FetcherException
- If there is an error saving the trackbackpublic void loadTrackback(Blog blog, Trackback trackback) throws FetcherException
Trackback
loadTrackback
in interface Fetcher
blog
- Blog
trackback
- Trackback
to load
FetcherException
- If there is an error loading the trackbackpublic void deleteTrackback(Blog blog, Trackback trackback) throws FetcherException
Trackback
deleteTrackback
in interface Fetcher
blog
- Blog
trackback
- Trackback
to delete
FetcherException
- If there is an error deleting the trackbackpublic java.util.List loadRecentTrackbacks(Blog blog) throws FetcherException
loadRecentTrackbacks
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error retrieving the recent trackbackspublic void savePingback(Blog blog, Pingback pingback) throws FetcherException
Pingback
savePingback
in interface Fetcher
blog
- Blog
pingback
- Pingback
to save
FetcherException
- If there is an error saving the pingbackpublic void loadPingback(Blog blog, Pingback pingback) throws FetcherException
Pingback
loadPingback
in interface Fetcher
blog
- Blog
pingback
- Pingback
to load
FetcherException
- If there is an error loading the pingbackpublic Pingback loadPingback(Blog blog, java.lang.String sourceURI, java.lang.String targetURI) throws FetcherException
loadPingback
in interface Fetcher
blog
- Blog
sourceURI
- Source URItargetURI
- Target URI
Pingback
given the source and target URIs or null
if not found
FetcherException
- If there was an erorr loading the pingbackpublic void deletePingback(Blog blog, Pingback pingback) throws FetcherException
Pingback
deletePingback
in interface Fetcher
blog
- Blog
pingback
- Pingback
to delete
FetcherException
- If there is an error deleting the pingbackpublic java.util.List loadRecentPingbacks(Blog blog) throws FetcherException
loadRecentPingbacks
in interface Fetcher
blog
- Blog
FetcherException
- If there is an error retrieving the recent pingbackspublic User loadUser(Blog blog, java.lang.String userLogin) throws FetcherException
User
from a blog
loadUser
in interface Fetcher
blog
- Blog
userLogin
- Login ID
User
user
FetcherException
- If there is an error loading the User
from the blogpublic User[] getUsers(Blog blog)
getUsers
in interface Fetcher
blog
- Blog
User
s for a blogpublic User loadUser(Blog blog, java.lang.Integer userID) throws FetcherException
User
from a blog given their ID
loadUser
in interface Fetcher
blog
- Blog
userID
- User ID
User
object
FetcherException
- If there is an error loading the userpublic User saveUser(Blog blog, User user) throws FetcherException
User
to the blog
saveUser
in interface Fetcher
blog
- Blog
user
- User
User
object
FetcherException
- If there is an error saving the user to the blogpublic void deleteUser(Blog blog, java.lang.Integer userID) throws FetcherException
deleteUser
in interface Fetcher
blog
- Blog
userID
- User ID
FetcherException
- If there is an error deleting the user from the blogpublic java.util.List findResponsesByStatus(Blog blog, java.lang.String[] status) throws FetcherException
Blog
matching one of a set of status codes
findResponsesByStatus
in interface Fetcher
blog
- Blog
status
- List of status codes to load
FetcherException
- If there is an error loading the responsespublic java.util.List findResponsesByQuery(Blog blog, java.lang.String query) throws FetcherException
Blog
matching some query
findResponsesByQuery
in interface Fetcher
blog
- Blog
query
- Query which will match on various items such as commenter name, e-mail, IP address, etc.
FetcherException
- If there is an error loading the responsespublic void handleEvent(Event event)
handleEvent
in interface Listener
event
- Event
to be handledpublic void processEvent(Event event)
processEvent
in interface Listener
event
- Event
to be handledpublic void destroy() throws FetcherException
BlojsomServlet
is taken out of service
destroy
in interface Fetcher
FetcherException
- If there is an error in finalizing this fetcher
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |