Class HibernateBlogPostDao
java.lang.Object
org.springframework.dao.support.DaoSupport
com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao<T>
com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao<T>
com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao<BlogPost>
com.atlassian.confluence.pages.persistence.dao.hibernate.HibernateBlogPostDao
- All Implemented Interfaces:
BlogPostDao
,org.springframework.beans.factory.InitializingBean
public class HibernateBlogPostDao
extends VersionedHibernateObjectDao<BlogPost>
implements BlogPostDao
Hibernate implementation of the BlogPost DAO
-
Nested Class Summary
Nested classes/interfaces inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
HibernateObjectDao.Cacheability
-
Field Summary
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Counts the number of published blog posts that have unpublished changes.int
Counts the total number of current blog posts across all spacesint
Counts the number of blog posts that are drafts.@Nullable BlogPost
getBlogPost
(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments) Get the blog post by name and date.getBlogPostByTitle
(String spaceKey, String title) Get a blog post by name.int
Counts the total number of blog posts, for all spaces and posting dates.long
getBlogPostCount
(String spaceKey, Calendar date, int period) Get total number of blogPost.getBlogPostDates
(@NonNull Space space) Returns a list of creation dates for all the blog posts in a space.getBlogPostDates
(String spaceKey, Calendar date, int period) Returns a list of creation dates for all the blog posts in a space for a particular period.getBlogPosts
(@NonNull Space space, @NonNull Calendar date, int period) Get the blog posts in a space for a particular period.getBlogPosts
(@NonNull Space space, @NonNull Calendar date, int period, int startIndex, int maxResultCount) Get list of blogPost by Date.getBlogPosts
(Space space, boolean currentOnly) Return an iterator for the specified space.getBlogPostsInTrash
(String spaceKey, String title) Gets a blog post that is in the trash for a given space that matches the given title.Fetches statistics about blog postsprotected BlogPost
getByClassId
(long id) Retrieve the object with a particular id from the database.getById
(long id) Get a blog post by id.int
getCommentCountOnBlog
(long blogId) Get count of comments on a blogpost.Return a list of ids for all current blog posts.getFirstPostAfter
(BlogPost post) Used for finding the "previous" post to an existing post.getFirstPostAfter
(String spaceKey, Date creationDate) Used for finding the "previous" post to an existing postgetFirstPostBefore
(BlogPost post) Used for finding the "previous" post to an existing post.getFirstPostBefore
(String spaceKey, Date creationDate) Used for finding the "previous" post to an existing postgetMostRecentBlogPost
(String spaceKey) getRecentlyAddedBlogPosts
(int maxCount, @Nullable String spaceKey) Get list of recently created blog posts.getRecentlyAddedBlogPosts
(int maxPosts, Date timeSince, String spaceKey) protected void
void
setEventPublisher
(com.atlassian.event.api.EventPublisher eventPublisher) Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.VersionedHibernateObjectDao
applyChildVersioningPolicy, findAllSorted, findLatestVersionsCount, findLatestVersionsIterator, findLatestVersionsIterator, findNamedQueryStringParams, findNamedQueryStringParams, remove, save
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.ConfluenceHibernateObjectDao
updateModificationData
Methods inherited from class com.atlassian.confluence.core.persistence.hibernate.HibernateObjectDao
applyTransactionTimeout, applyTransactionTimeout, checkDaoConfig, createHibernateTemplate, findAll, findAllSorted, findNamedQuery, findNamedQuery, findNamedQuery, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParam, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findNamedQueryStringParams, findSingleObject, getCountResult, getHibernateTemplate, getSessionFactory, reIndex, save, saveEntity, saveRaw, setHibernateTemplate, setSessionFactory, uniqueResult
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
-
Constructor Details
-
HibernateBlogPostDao
public HibernateBlogPostDao()
-
-
Method Details
-
getPersistentClass
- Specified by:
getPersistentClass
in classHibernateObjectDao<BlogPost>
-
getById
Description copied from interface:BlogPostDao
Get a blog post by id. Will return null if the post does not exist- Specified by:
getById
in interfaceBlogPostDao
-
getByClassId
Description copied from class:HibernateObjectDao
Retrieve the object with a particular id from the database. The object must be of the same class as the DAO's getPersistentClass() method returns.- Overrides:
getByClassId
in classHibernateObjectDao<BlogPost>
- Parameters:
id
- the id of the object to look up- Returns:
- the corresponding object, or null if the object does not exist with the appropriate class and id.
-
getBlogPostByTitle
Description copied from interface:BlogPostDao
Get a blog post by name. If there is no blog post by that name, or if the name is ambiguous (there are multiple blog posts by that name on different dates), the method will return null- Specified by:
getBlogPostByTitle
in interfaceBlogPostDao
- Parameters:
spaceKey
- the spacetitle
- the title- Returns:
- the blog post in that key with that title, or null if there is no such post, or the title does not unambiguously refer to a single blog entry.
-
getBlogPostsInTrash
Description copied from interface:BlogPostDao
Gets a blog post that is in the trash for a given space that matches the given title.- Specified by:
getBlogPostsInTrash
in interfaceBlogPostDao
- Parameters:
spaceKey
- The space key (case-insensitive) in which to look for the blogtitle
- The title (case-insensitive) of the blog to look for- Returns:
- a list of blog posts in the trash that have the given title and space key.
-
getBlogPost
public @Nullable BlogPost getBlogPost(@NonNull Space space, @NonNull String title, @NonNull Calendar day, boolean eagerLoadComments) Description copied from interface:BlogPostDao
Get the blog post by name and date. If there is no blog post by that name on that date, the method will return null- Specified by:
getBlogPost
in interfaceBlogPostDao
- Parameters:
space
- the space to look for the post intitle
- the title of the post we are looking forday
- the DAY the post was created on. Any part of the calendar more specific than a day will be ignored
-
getBlogPosts
Description copied from interface:BlogPostDao
Get the blog posts in a space for a particular period.TODO: add Calendar.WEEK range support.
- Specified by:
getBlogPosts
in interfaceBlogPostDao
- Parameters:
space
- the space to look for posts indate
- a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.period
- one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supported- Returns:
- a list of blog posts in that time-range. The list may be empty but will never be null
-
getBlogPosts
public List<BlogPost> getBlogPosts(@NonNull Space space, @NonNull Calendar date, int period, int startIndex, int maxResultCount) Description copied from interface:BlogPostDao
Get list of blogPost by Date.- Specified by:
getBlogPosts
in interfaceBlogPostDao
- Parameters:
space
- the space to look for posts indate
- a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.period
- one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supportedstartIndex
- start number of postsmaxResultCount
- Maximum number of posts to return- Returns:
- a list of blogPost
-
getBlogPostCount
Description copied from interface:BlogPostDao
Get total number of blogPost.- Specified by:
getBlogPostCount
in interfaceBlogPostDao
- Parameters:
spaceKey
- the space to look for posts indate
- a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.period
- one of the Calendar constants specifying the granularity of the search. currently, only Calendar.MONTH and Calendar.DATE are supported- Returns:
- a count number of blogPosts
-
getBlogPostDates
Description copied from interface:BlogPostDao
Returns a list of creation dates for all the blog posts in a space.- Specified by:
getBlogPostDates
in interfaceBlogPostDao
-
getBlogPostDates
Description copied from interface:BlogPostDao
Returns a list of creation dates for all the blog posts in a space for a particular period.- Specified by:
getBlogPostDates
in interfaceBlogPostDao
- Parameters:
spaceKey
- the space to look for posts in.date
- a calendar object representing the date range we are looking for. Any part of the calendar more specific than the supplied period will be ignored.period
- one of the Calendar constants specifying the granularity of the search. currently, only Calendar.YEAR, Calendar.MONTH and Calendar.DATE are supported- Returns:
- a list creation dates for the blog posts created in the time-range. The list may be empty but will never be null
-
getBlogPosts
Description copied from interface:BlogPostDao
Return an iterator for the specified space. This is an efficient alternative to space.getBlogPosts- Specified by:
getBlogPosts
in interfaceBlogPostDao
-
getCurrentBlogPostIds
Description copied from interface:BlogPostDao
Return a list of ids for all current blog posts.- Specified by:
getCurrentBlogPostIds
in interfaceBlogPostDao
-
getRecentlyAddedBlogPosts
Description copied from interface:BlogPostDao
Get list of recently created blog posts.- Specified by:
getRecentlyAddedBlogPosts
in interfaceBlogPostDao
- Parameters:
maxCount
- Maximum number of posts to returnspaceKey
- the spaceKey to look for the posts in. If this key is null, we look acrosns all spaces- Returns:
- a list of the most recently added blog posts. The list can be empty but will never be null.
-
getFirstPostBefore
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post- Specified by:
getFirstPostBefore
in interfaceBlogPostDao
- Parameters:
spaceKey
- the space to look increationDate
- the date the post must be before- Returns:
- the first post created before that date, or null if there are none.
-
getFirstPostAfter
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post- Specified by:
getFirstPostAfter
in interfaceBlogPostDao
- Parameters:
spaceKey
- the space to look increationDate
- the date the post must be after- Returns:
- the first post created after that date, or null if there are none
-
getFirstPostBefore
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post. If you are comparing blog posts, you should always prefer this over the method that takes a date, because this method will avoid date comparison bugs that can sneak in with certain databases. (*cough* Oracle)- Specified by:
getFirstPostBefore
in interfaceBlogPostDao
- Parameters:
post
- the blog post that this must preceed- Returns:
- the first post created before the given blog post, or null if there are none.
-
getFirstPostAfter
Description copied from interface:BlogPostDao
Used for finding the "previous" post to an existing post. If you are comparing blog posts, you should always prefer this over the method that takes a date, because this method will avoid date comparison bugs that can sneak in with certain databases. (*cough* Oracle)- Specified by:
getFirstPostAfter
in interfaceBlogPostDao
- Parameters:
post
- the blog post that this must be after- Returns:
- the first post created after the given blog post, or null if there are none.
-
getRecentlyAddedBlogPosts
- Specified by:
getRecentlyAddedBlogPosts
in interfaceBlogPostDao
-
getMostRecentBlogPost
- Specified by:
getMostRecentBlogPost
in interfaceBlogPostDao
-
getBlogPostCount
public int getBlogPostCount()Description copied from interface:BlogPostDao
Counts the total number of blog posts, for all spaces and posting dates.- Specified by:
getBlogPostCount
in interfaceBlogPostDao
- Returns:
- the number of blog posts
-
countCurrentBlogs
public int countCurrentBlogs()Description copied from interface:BlogPostDao
Counts the total number of current blog posts across all spaces- Specified by:
countCurrentBlogs
in interfaceBlogPostDao
- Returns:
- the number of current blog posts
-
countDraftBlogs
public int countDraftBlogs()Description copied from interface:BlogPostDao
Counts the number of blog posts that are drafts. This does not include drafts of blog posts that have already been published (i.e. blog posts with unpublished changes).- Specified by:
countDraftBlogs
in interfaceBlogPostDao
- Returns:
- the number of draft blog posts
-
countBlogsWithUnpublishedChanges
public int countBlogsWithUnpublishedChanges()Description copied from interface:BlogPostDao
Counts the number of published blog posts that have unpublished changes.- Specified by:
countBlogsWithUnpublishedChanges
in interfaceBlogPostDao
- Returns:
- the number of blog posts with unpublished changes.
-
getBlogPostStatistics
Description copied from interface:BlogPostDao
Fetches statistics about blog posts- Specified by:
getBlogPostStatistics
in interfaceBlogPostDao
- Returns:
- a BlogPostStatisticsDTO with statistics about blogs such as total, current, and draft count
-
getCommentCountOnBlog
public int getCommentCountOnBlog(long blogId) Description copied from interface:BlogPostDao
Get count of comments on a blogpost.- Specified by:
getCommentCountOnBlog
in interfaceBlogPostDao
- Parameters:
blogId
- id of the blogpost- Returns:
- the number of comments on the blogpost
-
setEventPublisher
public void setEventPublisher(com.atlassian.event.api.EventPublisher eventPublisher) -
publishEvent
- Overrides:
publishEvent
in classHibernateObjectDao<BlogPost>
-