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.runtime.plugin.component.AbstractLogEnabled;
020import org.ametys.web.repository.page.Page;
021import org.ametys.web.repository.page.PagesContainer;
022import org.ametys.web.repository.site.Site;
023
024/**
025 * Default implementation of a {@link CacheInvalidationPolicy}
026 */
027public class DefaultCacheInvalidationPolicy extends AbstractLogEnabled implements CacheInvalidationPolicy
028{
029
030    @Override
031    public void invalidateCacheOnPageModification(Page page) throws Exception
032    {
033        CacheHelper.invalidateCache(page.getSite(), getLogger());
034    }
035   
036    @Override
037    public void invalidateCacheOnPageMinorChange(Page page) throws Exception
038    {
039        CacheHelper.invalidateCache(page, getLogger());
040    }
041    
042    @Override
043    public void invalidateCacheOnPageDeletion(Site site, PagesContainer parent, String pageId, String pathInSitemap) throws Exception
044    {
045        CacheHelper.invalidateCache(site, getLogger());
046    }
047    
048    @Override
049    public void invalidateCacheOnPageMove(Page page, PagesContainer oldParent, String oldPathInSitemap) throws Exception
050    {
051        CacheHelper.invalidateCache(page.getSite(), getLogger());
052    }
053    
054    @Override
055    public void invalidateCacheOnContentCommented(Page page, Content content) throws Exception
056    {
057        CacheHelper.invalidateCache(page, getLogger());
058    }
059    
060    @Override
061    public void invalidateCacheOnContentReactionChanged(Page page, Content content) throws Exception
062    {
063        CacheHelper.invalidateCache(page, getLogger());
064    }
065    
066    @Override
067    public void invalidateCacheOnContentDeletion(Site site, String contentId) throws Exception
068    {
069        CacheHelper.invalidateCache(site, getLogger());
070    }
071    
072    @Override
073    public void invalidateCacheOnContentModification(Site site, Content content) throws Exception
074    {
075        CacheHelper.invalidateCache(site, getLogger());
076    }
077}