001/*
002 *  Copyright 2011 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.web.cache;
017
018import org.ametys.cms.repository.Content;
019import org.ametys.web.repository.page.Page;
020import org.ametys.web.repository.page.PagesContainer;
021import org.ametys.web.repository.site.Site;
022
023
024/**
025 * Component responsible for policy of cache invalidation
026 */
027public interface CacheInvalidationPolicy
028{
029    /** Avalon Role */
030    public static final String ROLE = CacheInvalidationPolicy.class.getName();
031    
032    /**
033     * Invalidate cache when a page is modified.
034     * The page modification can have triggered the modification of other pages (ex: page addition, content zone item deletion).
035     * @param page the modified page
036     * @throws Exception if an error occurs
037     */
038    public void invalidateCacheOnPageModification(Page page) throws Exception;
039    
040    /**
041     * Invalidate cache on a minor page change.
042     * The change cannot have triggered the modification of other pages (ex: service modification).
043     * @param page the modified page
044     * @throws Exception if an error occurs
045     */
046    public void invalidateCacheOnPageMinorChange(Page page) throws Exception;
047    
048    /**
049     * Invalidate cache on a page deletion
050     * @param site the site
051     * @param parent the parent page or sitemap
052     * @param pageId the page id
053     * @param pathInSitemap path of the page in sitemap
054     * @throws Exception if an error occurs
055     */
056    public void invalidateCacheOnPageDeletion(Site site, PagesContainer parent, String pageId, String pathInSitemap) throws Exception;
057    
058    /**
059     * Invalidate cache on a page move
060     * @param page the page moved
061     * @param oldParent the old parent
062     * @param oldPathInSitemap the old path in sitemap
063     * @throws Exception if an error occurs
064     */
065    public void invalidateCacheOnPageMove(Page page, PagesContainer oldParent, String oldPathInSitemap) throws Exception;
066    
067    /**
068     * Invalidate cache on a content commented
069     * @param page the page 
070     * @param content the commented content
071     * @throws Exception if an error occurs
072     */
073    public void invalidateCacheOnContentCommented (Page page, Content content) throws Exception;
074    
075    /**
076     * Invalidate cache when a content reaction changed
077     * @param page the page 
078     * @param content the commented content
079     * @throws Exception if an error occurs
080     */
081    public void invalidateCacheOnContentReactionChanged (Page page, Content content) throws Exception;
082    
083    /**
084     * Invalidate cache on a content deleted
085     * @param site the site
086     * @param contentId the content id
087     * @throws Exception if an error occurs
088     */
089    public void invalidateCacheOnContentDeletion (Site site, String contentId) throws Exception;
090    
091    /**
092     * Invalidate cache on a content modfication
093     * @param site the site
094     * @param content the content
095     * @throws Exception if an error occurs
096     */
097    public void invalidateCacheOnContentModification (Site site, Content content) throws Exception;
098}