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 Classes Modifier and Type Class Description protected static class
BlogCacheManager.AllPostCache
Cache of all the posts.protected static class
BlogCacheManager.FuturePostCache
Cache of identifier of the future posts.static class
BlogCacheManager.Post
Class representing a Post in the cache.protected static class
BlogCacheManager.PostDateCache
Post cache by date.protected static class
BlogCacheManager.PostSiteLang
A Post with site name and language.protected static class
BlogCacheManager.PostTagCache
Post cache by tag.class
BlogCacheManager.ReverseDatePostComparator
Reverse date post comparator.
-
Field Summary
Fields Modifier and Type Field Description protected AmetysObjectResolver
_ametysResolver
The ametys object resolver.protected BlogPageHandler
_blogRootHandler
The blog root page handler.protected AbstractCacheManager
_cacheManager
CacheManager used to create and get cacheprotected ObservationManager
_observationManager
The observation managerprotected AmetysObjectResolver
_resolver
The Ametys resolverprotected SiteConfigurationExtensionPoint
_siteConf
The site configuration extension pointprotected SiteManager
_siteManager
The Site manager.protected TagProviderExtensionPoint
_tagProviderEP
Th tag providerprotected WorkspaceSelector
_workspaceSelector
The workspace selector.static String
POST_DATE_ATTRIBUTE
The name of the date attribute of poststatic String
POST_TAGS_ATTRIBUTE
The name of the tags attribute of poststatic String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description BlogCacheManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPost(String siteName, String language, Content postContent)
Add a post content to the cache.void
clearCaches()
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
dispatchPost(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post)
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.Set<Integer>
getMonths(String siteName, String language, int year)
Get the months with posts for a specified year.protected BlogCacheManager.PostSiteLang
getPost(String siteName, String postId)
Get a post by its site name and id.BlogCacheManager.Post
getPost(String siteName, String language, String id)
Test if a post exists, provided its ID.BlogCacheManager.Post
getPost(String siteName, String language, String tagName, String id)
Get the posts for a year-month couple.BlogCacheManager.Post
getPostByName(String siteName, String language, int year, int month, String name)
Get the posts for a year-month couple.BlogCacheManager.Post
getPostByName(String siteName, String language, String name)
Test if a post exists, provided its content name.BlogCacheManager.Post
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.Set<String>
getPostIds(String siteName, String language)
Get a list of all the posts' IDs.Map<String,BlogCacheManager.Post>
getPosts(String siteName, String language)
Get the exhaustive list of Posts.Map<String,BlogCacheManager.Post>
getPostsByMonth(String siteName, String language, int year, int month)
Get the posts for a year-month couple.Map<String,BlogCacheManager.Post>
getPostsByTag(String siteName, String language, String tagName)
Get the posts for a given tag.Map<String,BlogCacheManager.Post>
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.Collection<BlogCacheManager.Post>
getSortedPosts(String siteName, String language)
Get the exhaustive list of Posts.Collection<BlogCacheManager.Post>
getSortedPostsByMonth(String siteName, String language, int year, int month)
Get the posts for a year-month couple.Collection<BlogCacheManager.Post>
getSortedPostsByTag(String siteName, String language, String tagName)
Get the posts for a given tag.Collection<BlogCacheManager.Post>
getSortedPostsByTag(String siteName, String language, String tagName, boolean deepSearch)
Get the posts for a given tag.Collection<BlogCacheManager.Post>
getSortedPostsByYear(String siteName, String language, int year)
Get the posts for a year.Set<String>
getTags(String siteName, String language)
Get the tags for a site and language.Set<Integer>
getYears(String siteName, String language)
Get the years with posts.boolean
hasMonth(String siteName, String language, int year, int month)
Get the years with posts.boolean
hasPost(String siteName, String language, int year, int month, String id)
Get the posts for a year-month couple.boolean
hasPost(String siteName, String language, String id)
Test if a post exists, provided its ID.boolean
hasPost(String siteName, String language, String tagName, String id)
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
hasTag(String siteName, String language, String tagName)
Test if a tag exists in the given site and language.boolean
hasYear(String siteName, String language, int year)
Get the years with posts.void
initialize()
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
removePost(BlogCacheManager.FuturePostCache cache, BlogCacheManager.Post post)
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 Detail
-
POST_DATE_ATTRIBUTE
public static final String POST_DATE_ATTRIBUTE
The name of the date attribute of post- See Also:
- Constant Field Values
-
POST_TAGS_ATTRIBUTE
public static final String POST_TAGS_ATTRIBUTE
The name of the tags attribute of post- See Also:
- Constant Field Values
-
_ametysResolver
protected AmetysObjectResolver _ametysResolver
The ametys object resolver.
-
_tagProviderEP
protected TagProviderExtensionPoint _tagProviderEP
Th tag provider
-
_siteManager
protected SiteManager _siteManager
The Site manager.
-
_siteConf
protected SiteConfigurationExtensionPoint _siteConf
The site configuration extension point
-
_blogRootHandler
protected BlogPageHandler _blogRootHandler
The blog root page handler.
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys resolver
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_cacheManager
protected AbstractCacheManager _cacheManager
CacheManager used to create and get cache
-
-
Constructor Detail
-
BlogCacheManager
public BlogCacheManager()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
hasYear
public boolean hasYear(String siteName, String language, int year)
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
public Set<Integer> getYears(String siteName, String language)
Get the years with posts.- Parameters:
siteName
- the site name.language
- the language.- Returns:
- the years with posts as a Set of Integer.
-
hasMonth
public boolean hasMonth(String siteName, String language, int year, int month)
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
public Set<Integer> getMonths(String siteName, String language, int year)
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
public Map<String,BlogCacheManager.Post> getPostsByYear(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.
-
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
public boolean hasPost(String siteName, String language, int year, int month, String id)
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
public boolean hasPostByName(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 of post- Returns:
- the posts in the specified year and month.
-
getTags
public Set<String> getTags(String siteName, String language)
Get the tags for a site and language.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the tag list.
-
hasTag
public boolean hasTag(String siteName, String language, String tagName)
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
public boolean hasPostByTag(String siteName, String language, String tagName, String postId)
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
public BlogCacheManager.Post getPost(String siteName, String language, String tagName, String id)
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
public boolean hasPost(String siteName, String language, String tagName, String id)
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
public boolean hasPostByName(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.
-
getPostIds
public Set<String> getPostIds(String siteName, String language)
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
public Map<String,BlogCacheManager.Post> getPosts(String siteName, String language)
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
public Collection<BlogCacheManager.Post> getSortedPosts(String siteName, String language)
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
public BlogCacheManager.Post getPost(String siteName, String language, String id)
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
public BlogCacheManager.Post getPostByName(String siteName, String language, String name)
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
public boolean hasPost(String siteName, String language, String id)
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
public boolean hasPostByName(String siteName, String language, String name)
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
public void addPost(String siteName, String language, Content postContent)
Add a post content to the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
modifyPost
public void modifyPost(String siteName, String language, Content postContent)
Modify a post content in the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
validatePost
public void validatePost(String siteName, String language, Content postContent)
Validate a post content.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
removePost
public void removePost(String siteName, String language, Content postContent)
Remove a post content from the cache.- Parameters:
siteName
- The site namelanguage
- The languagepostContent
- The content
-
removePostById
public void removePostById(String siteName, String postId)
Remove a post content from the cache.- Parameters:
siteName
- the site name.postId
- the post ID.
-
clearCaches
public void clearCaches()
Clear the caches.
-
clearCaches
public void clearCaches(String siteName, String language)
Clear the caches for a given siteName and language.- Parameters:
siteName
- The site namelanguage
- The language
-
getPostDateCache
protected BlogCacheManager.PostDateCache getPostDateCache(String siteName, String language)
Get the post date cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post date cache for the given site and language.
-
getPostTagCache
protected BlogCacheManager.PostTagCache getPostTagCache(String siteName, String language)
Get the post tag cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post tag cache for the given site and language.
-
getAllPostCache
protected BlogCacheManager.AllPostCache getAllPostCache(String siteName, String language)
Get the exhaustive post cache.- Parameters:
siteName
- The site namelanguage
- The language- Returns:
- the post date cache for the given site and language.
-
getFuturePostCache
protected BlogCacheManager.FuturePostCache getFuturePostCache(String siteName, String language)
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
protected void initializeCaches(String workspaceName, String siteName, String language)
Initialize all the caches.- Parameters:
workspaceName
- The workspace namesiteName
- The site namelanguage
- The language
-
getPost
protected BlogCacheManager.PostSiteLang getPost(String siteName, String postId)
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
protected BlogCacheManager.PostSiteLang getFuturePost(String siteName, String postId)
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
protected void dispatchPost(BlogCacheManager.PostDateCache dateCache, Content content)
Dispatch a post content in the post date cache.- Parameters:
dateCache
- the post date cache.content
- the Post content.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post)
Add a post in the post date cache.- Parameters:
dateCache
- the post date cache.post
- the Post to add.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.PostTagCache tagCache, Content content)
Dispatch a post content in the post tag cache.- Parameters:
tagCache
- the post tag cache.content
- the Post content.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.PostTagCache tagCache, BlogCacheManager.Post post)
Dispatch a post in the post tag cache.- Parameters:
tagCache
- the post tag cache.post
- the Post to add.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.AllPostCache cache, Content content)
Dispatch a post content in the post cache.- Parameters:
cache
- the post cache.content
- the Post content.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post)
Dispatch a post in the post cache.- Parameters:
cache
- the post cache.post
- the Post content.
-
dispatchPost
protected void dispatchPost(BlogCacheManager.FuturePostCache cache, Content content)
Dispatch a post content in the future post cache.- Parameters:
cache
- the future post cache.content
- the Post content.
-
removePost
protected void removePost(BlogCacheManager.PostDateCache dateCache, Content content)
Remove a post content.- Parameters:
dateCache
- the post date cache.content
- the Post content.
-
removePost
protected void removePost(BlogCacheManager.PostDateCache dateCache, BlogCacheManager.Post post)
Remove a post content.- Parameters:
dateCache
- the post date cache.post
- the Post object to remove.
-
removePost
protected void removePost(BlogCacheManager.PostTagCache cache, Content content)
Remove a post content.- Parameters:
cache
- the post tag cache.content
- the Post content.
-
removePost
protected void removePost(BlogCacheManager.PostTagCache cache, BlogCacheManager.Post post)
Remove a post content.- Parameters:
cache
- the post tag cache.post
- the Post to remove.
-
removePost
protected void removePost(BlogCacheManager.AllPostCache cache, Content content)
Remove a post content.- Parameters:
cache
- the post cache.content
- the Post content.
-
removePost
protected void removePost(BlogCacheManager.AllPostCache cache, BlogCacheManager.Post post)
Remove a post content.- Parameters:
cache
- the post cache.post
- the Post to remove.
-
removePost
protected void removePost(BlogCacheManager.FuturePostCache cache, Content content)
Remove a future post content.- Parameters:
cache
- the future post cache.content
- the Post content to remove.
-
removePost
protected void removePost(BlogCacheManager.FuturePostCache cache, BlogCacheManager.Post post)
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.
-
-