Package org.ametys.plugins.blog
Class BlogCacheManager
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.plugins.blog.BlogCacheManager
- All Implemented Interfaces:
Initializable
,Component
,LogEnabled
,Serviceable
public class BlogCacheManager
extends AbstractLogEnabled
implements Component, Serviceable, Initializable
Blog cache manager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
Cache of all the posts.protected static class
Cache of identifier of the future posts.static class
Class representing a Post in the cache.protected static class
Post cache by date.protected static class
A Post with site name and language.protected static class
Post cache by tag.class
Reverse date post comparator. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AmetysObjectResolver
The ametys object resolver.protected BlogPageHandler
The blog root page handler.protected AbstractCacheManager
CacheManager used to create and get cacheprotected ObservationManager
The observation managerprotected AmetysObjectResolver
The Ametys resolverprotected SiteConfigurationExtensionPoint
The site configuration extension pointprotected SiteManager
The Site manager.protected TagProviderExtensionPoint
Th tag providerprotected WorkspaceSelector
The workspace selector.static final String
The name of the date attribute of poststatic final String
The name of the tags attribute of poststatic final String
The avalon role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a post content to the cache.void
Clear the caches.void
clearCaches
(String siteName, String language) Clear the caches for a given siteName and language.protected void
dispatchPost
(BlogCacheManager.AllPostCache cache, Content content) Dispatch a post content in the post cache.protected void
Dispatch a post in the post cache.protected void
dispatchPost
(BlogCacheManager.FuturePostCache cache, Content content) Dispatch a post content in the future post cache.protected void
dispatchPost
(BlogCacheManager.PostDateCache dateCache, Content content) Dispatch a post content in the post date cache.protected void
dispatchPost
(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post) Add a post in the post date cache.protected void
dispatchPost
(BlogCacheManager.PostTagCache tagCache, Content content) Dispatch a post content in the post tag cache.protected void
dispatchPost
(BlogCacheManager.PostTagCache tagCache, BlogCacheManager.Post post) Dispatch a post in the post tag cache.protected BlogCacheManager.AllPostCache
getAllPostCache
(String siteName, String language) Get the exhaustive post cache.protected BlogCacheManager.PostSiteLang
getFuturePost
(String siteName, String postId) Get a future post by its site name and id.protected BlogCacheManager.FuturePostCache
getFuturePostCache
(String siteName, String language) Get the future post cache.Get the months with posts for a specified year.protected BlogCacheManager.PostSiteLang
Get a post by its site name and id.Test if a post exists, provided its ID.Get the posts for a year-month couple.getPostByName
(String siteName, String language, int year, int month, String name) Get the posts for a year-month couple.getPostByName
(String siteName, String language, String name) Test if a post exists, provided its content name.getPostByName
(String siteName, String language, String tagName, String name) Get the posts for a year-month couple.protected BlogCacheManager.PostDateCache
getPostDateCache
(String siteName, String language) Get the post date cache.getPostIds
(String siteName, String language) Get a list of all the posts' IDs.Get the exhaustive list of Posts.getPostsByMonth
(String siteName, String language, int year, int month) Get the posts for a year-month couple.getPostsByTag
(String siteName, String language, String tagName) Get the posts for a given tag.getPostsByYear
(String siteName, String language, int year) Get the posts for a year.protected BlogCacheManager.PostTagCache
getPostTagCache
(String siteName, String language) Get the post tag cache.getSortedPosts
(String siteName, String language) Get the exhaustive list of Posts.getSortedPostsByMonth
(String siteName, String language, int year, int month) Get the posts for a year-month couple.getSortedPostsByTag
(String siteName, String language, String tagName) Get the posts for a given tag.getSortedPostsByTag
(String siteName, String language, String tagName, boolean deepSearch) Get the posts for a given tag.getSortedPostsByYear
(String siteName, String language, int year) Get the posts for a year.Get the tags for a site and language.Get the years with posts.boolean
Get the years with posts.boolean
Get the posts for a year-month couple.boolean
Test if a post exists, provided its ID.boolean
Get the posts for a year-month couple.boolean
hasPostByName
(String siteName, String language, int year, int month, String name) Get the posts for a year-month couple.boolean
hasPostByName
(String siteName, String language, String name) Test if a post exists, provided its content name.boolean
hasPostByName
(String siteName, String language, String tagName, String name) Get the posts for a year-month couple.boolean
hasPostByTag
(String siteName, String language, String tagName, String postId) Test if a given post has a tag, by its ID.boolean
Test if a tag exists in the given site and language.boolean
Get the years with posts.void
protected void
initializeCaches
(String workspaceName, String siteName, String language) Initialize all the caches.void
modifyPost
(String siteName, String language, Content postContent) Modify a post content in the cache.protected void
modifyPost
(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post, Content postContent) Modify a post content.protected void
modifyPost
(BlogCacheManager.FuturePostCache cache, BlogCacheManager.Post post, Content postContent) Modify a future post content.protected void
modifyPost
(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post, Content postContent) Remove a post content.protected void
modifyPost
(BlogCacheManager.PostTagCache cache, BlogCacheManager.Post post, Content postContent) Remove a post content.void
removePost
(String siteName, String language, Content postContent) Remove a post content from the cache.protected void
removePost
(BlogCacheManager.AllPostCache cache, Content content) Remove a post content.protected void
removePost
(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post) Remove a post content.protected void
removePost
(BlogCacheManager.FuturePostCache cache, Content content) Remove a future post content.protected void
Remove a future post content.protected void
removePost
(BlogCacheManager.PostDateCache dateCache, Content content) Remove a post content.protected void
removePost
(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post) Remove a post content.protected void
removePost
(BlogCacheManager.PostTagCache cache, Content content) Remove a post content.protected void
removePost
(BlogCacheManager.PostTagCache cache, BlogCacheManager.Post post) Remove a post content.void
removePostById
(String siteName, String postId) Remove a post content from the cache.void
service
(ServiceManager serviceManager) void
validatePost
(String siteName, String language, Content postContent) Validate a post content.Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
POST_DATE_ATTRIBUTE
The name of the date attribute of post- See Also:
-
POST_TAGS_ATTRIBUTE
The name of the tags attribute of post- See Also:
-
ROLE
The avalon role. -
_ametysResolver
The ametys object resolver. -
_tagProviderEP
Th tag provider -
_siteManager
The Site manager. -
_siteConf
The site configuration extension point -
_blogRootHandler
The blog root page handler. -
_workspaceSelector
The workspace selector. -
_resolver
The Ametys resolver -
_observationManager
The observation manager -
_cacheManager
CacheManager used to create and get cache
-
-
Constructor Details
-
BlogCacheManager
public BlogCacheManager()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
hasYear
Get the years with posts.- Parameters:
siteName
- the site name.language
- the language.year
- the year- Returns:
- the years with posts as a Set of Integer.
-
getYears
Get the years with posts.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the years with posts as a Set of Integer.
-
hasMonth
Get the years with posts.- Parameters:
siteName
- the site name.language
- the language.year
- the yearmonth
- the month- Returns:
- the years with posts as a Set of Integer.
-
getMonths
Get the months with posts for a specified year.- Parameters:
siteName
- the site name.language
- the language.year
- the year.- Returns:
- the months with posts in the specified year as a Set of Integer.
-
getPostsByMonth
public Map<String,BlogCacheManager.Post> getPostsByMonth(String siteName, String language, int year, int month) Get the posts for a year-month couple.- Parameters:
siteName
- the site name.language
- the language.year
- the year.month
- the month.- Returns:
- the posts in the specified year and month.
-
getSortedPostsByMonth
public Collection<BlogCacheManager.Post> getSortedPostsByMonth(String siteName, String language, int year, int month) Get the posts for a year-month couple.- Parameters:
siteName
- the site name.language
- the language.year
- the year.month
- the month.- Returns:
- the posts in the specified year and month.
-
getPostsByYear
Get the posts for a year.- Parameters:
siteName
- the site name.language
- the language.year
- the year.- Returns:
- the posts in the specified year.
-
getSortedPostsByYear
public Collection<BlogCacheManager.Post> getSortedPostsByYear(String siteName, String language, int year) Get the posts for a year.- Parameters:
siteName
- the site name.language
- the language.year
- the year.- Returns:
- the posts in the specified year.
-
getPostByName
public BlogCacheManager.Post getPostByName(String siteName, String language, int year, int month, String name) Get the posts for a year-month couple.- Parameters:
siteName
- the site name.language
- the language.year
- the year.month
- the month.name
- the name- Returns:
- the posts in the specified year and month.
-
hasPost
Get the posts for a year-month couple.- Parameters:
siteName
- the site name.language
- the language.year
- the year.month
- the month.id
- the id of post- Returns:
- the posts in the specified year and month.
-
hasPostByName
Get the posts for a year-month couple.- Parameters:
siteName
- the site name.language
- the language.year
- the year.month
- the month.name
- the name of post- Returns:
- the posts in the specified year and month.
-
getTags
Get the tags for a site and language.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the tag list.
-
hasTag
Test if a tag exists in the given site and language.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag name- Returns:
- true if the tag exists, false otherwise.
-
getPostsByTag
public Map<String,BlogCacheManager.Post> getPostsByTag(String siteName, String language, String tagName) Get the posts for a given tag.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag name- Returns:
- the tag posts, indexed by ID.
-
getSortedPostsByTag
public Collection<BlogCacheManager.Post> getSortedPostsByTag(String siteName, String language, String tagName) Get the posts for a given tag.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag name- Returns:
- the tag posts, indexed by ID.
-
getSortedPostsByTag
public Collection<BlogCacheManager.Post> getSortedPostsByTag(String siteName, String language, String tagName, boolean deepSearch) Get the posts for a given tag.- Parameters:
siteName
- The site namelanguage
- the languagetagName
- the tag namedeepSearch
- true to perform deep search- Returns:
- the tag posts, indexed by ID.
-
hasPostByTag
Test if a given post has a tag, by its ID.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag namepostId
- The id of post- Returns:
- true if the given post has the given tag.
-
getPost
Get the posts for a year-month couple.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag nameid
- The id of post- Returns:
- the posts in the specified year and month.
-
getPostByName
public BlogCacheManager.Post getPostByName(String siteName, String language, String tagName, String name) Get the posts for a year-month couple.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag namename
- the name of post- Returns:
- the posts in the specified year and month.
-
hasPost
Get the posts for a year-month couple.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag nameid
- The id of post- Returns:
- the posts in the specified year and month.
-
hasPostByName
Get the posts for a year-month couple.- Parameters:
siteName
- The site namelanguage
- The languagetagName
- The tag namename
- the name of post- Returns:
- the posts in the specified year and month.
-
getPostIds
Get a list of all the posts' IDs.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- all the posts' IDs as a Set.
-
getPosts
Get the exhaustive list of Posts.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the exhaustive list of Posts, indexed by their ID.
-
getSortedPosts
Get the exhaustive list of Posts.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the exhaustive list of Posts, indexed by their ID.
-
getPost
Test if a post exists, provided its ID.- Parameters:
id
- the post content ID.siteName
- the site name.language
- the language.- Returns:
- the Post.
-
getPostByName
Test if a post exists, provided its content name.- Parameters:
name
- the post content name.siteName
- the site name.language
- the language.- Returns:
- true if the post exists.
-
hasPost
Test if a post exists, provided its ID.- Parameters:
id
- the post content ID.siteName
- the site name.language
- the language.- Returns:
- true if the post exists.
-
hasPostByName
Test if a post exists, provided its content name.- Parameters:
name
- the post content name.siteName
- the site name.language
- the language.- Returns:
- true if the post exists.
-
addPost
Add a post content to the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
modifyPost
Modify a post content in the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
validatePost
Validate a post content.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
removePost
Remove a post content from the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
removePostById
Remove a post content from the cache.- Parameters:
siteName
- the site name.postId
- the post ID.
-
clearCaches
Clear the caches. -
clearCaches
Clear the caches for a given siteName and language.- Parameters:
siteName
- The site namelanguage
- The language
-
getPostDateCache
Get the post date cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post date cache for the given site and language.
-
getPostTagCache
Get the post tag cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post tag cache for the given site and language.
-
getAllPostCache
Get the exhaustive post cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post date cache for the given site and language.
-
getFuturePostCache
Get the future post cache.- Parameters:
siteName
- the name of the sitelanguage
- the language- Returns:
- the post date cache for the given site and language.
-
initializeCaches
Initialize all the caches.- Parameters:
workspaceName
- The workspace namesiteName
- The site namelanguage
- The language
-
getPost
Get a post by its site name and id.- Parameters:
siteName
- the site name.postId
- the post ID.- Returns:
- the Post if it exists in the cache, or null if it doesn't.
-
getFuturePost
Get a future post by its site name and id.- Parameters:
siteName
- the site name.postId
- the post ID.- Returns:
- the Post if it exists in the cache, or null if it doesn't.
-
dispatchPost
Dispatch a post content in the post date cache.- Parameters:
dateCache
- the post date cache.content
- the Post content.
-
dispatchPost
Add a post in the post date cache.- Parameters:
dateCache
- the post date cache.post
- the Post to add.
-
dispatchPost
Dispatch a post content in the post tag cache.- Parameters:
tagCache
- the post tag cache.content
- the Post content.
-
dispatchPost
Dispatch a post in the post tag cache.- Parameters:
tagCache
- the post tag cache.post
- the Post to add.
-
dispatchPost
Dispatch a post content in the post cache.- Parameters:
cache
- the post cache.content
- the Post content.
-
dispatchPost
Dispatch a post in the post cache.- Parameters:
cache
- the post cache.post
- the Post content.
-
dispatchPost
Dispatch a post content in the future post cache.- Parameters:
cache
- the future post cache.content
- the Post content.
-
removePost
Remove a post content.- Parameters:
dateCache
- the post date cache.content
- the Post content.
-
removePost
Remove a post content.- Parameters:
dateCache
- the post date cache.post
- the Post object to remove.
-
removePost
Remove a post content.- Parameters:
cache
- the post tag cache.content
- the Post content.
-
removePost
Remove a post content.- Parameters:
cache
- the post tag cache.post
- the Post to remove.
-
removePost
Remove a post content.- Parameters:
cache
- the post cache.content
- the Post content.
-
removePost
Remove a post content.- Parameters:
cache
- the post cache.post
- the Post to remove.
-
removePost
Remove a future post content.- Parameters:
cache
- the future post cache.content
- the Post content to remove.
-
removePost
Remove a future post content.- Parameters:
cache
- the future post cache.post
- the Post to remove.
-
modifyPost
protected void modifyPost(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post, Content postContent) Remove a post content.- Parameters:
dateCache
- the post date cache.post
- the post contentpostContent
- the post Content.
-
modifyPost
protected void modifyPost(BlogCacheManager.PostTagCache cache, BlogCacheManager.Post post, Content postContent) Remove a post content.- Parameters:
cache
- the post tag cache.post
- the post contentpostContent
- the post Content.
-
modifyPost
protected void modifyPost(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post, Content postContent) Modify a post content.- Parameters:
cache
- the post cache.post
- the post contentpostContent
- the post Content.
-
modifyPost
protected void modifyPost(BlogCacheManager.FuturePostCache cache, BlogCacheManager.Post post, Content postContent) Modify a future post content.- Parameters:
cache
- the post cache.post
- the postpostContent
- the post Content.
-