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.apache.avalon.framework.component.Component; 019import org.apache.avalon.framework.service.ServiceException; 020import org.apache.avalon.framework.service.ServiceManager; 021import org.apache.avalon.framework.service.Serviceable; 022 023import org.ametys.cms.repository.Content; 024import org.ametys.web.repository.page.Page; 025import org.ametys.web.repository.page.SitemapElement; 026import org.ametys.web.repository.site.Site; 027 028/** 029 * Default implementation of a {@link CacheInvalidationPolicy} 030 */ 031public class DefaultCacheInvalidationPolicy implements CacheInvalidationPolicy, Component, Serviceable 032{ 033 private FOCommHelper _foCommHelper; 034 035 public void service(ServiceManager manager) throws ServiceException 036 { 037 _foCommHelper = (FOCommHelper) manager.lookup(FOCommHelper.ROLE); 038 } 039 040 @Override 041 public void invalidateCacheOnPageModification(Page page) throws Exception 042 { 043 _foCommHelper.invalidateFOCache(page.getSite()); 044 } 045 046 @Override 047 public void invalidateCacheOnPageMinorChange(Page page) throws Exception 048 { 049 _foCommHelper.invalidateFOCache(page); 050 } 051 052 @Override 053 public void invalidateCacheOnPageDeletion(Site site, SitemapElement parent, String pageId, String pathInSitemap) throws Exception 054 { 055 _foCommHelper.invalidateFOCache(site); 056 } 057 058 @Override 059 public void invalidateCacheOnPageMove(Page page, SitemapElement oldParent, String oldPathInSitemap) throws Exception 060 { 061 _foCommHelper.invalidateFOCache(page.getSite()); 062 } 063 064 @Override 065 public void invalidateCacheOnContentCommented(Page page, Content content) throws Exception 066 { 067 _foCommHelper.invalidateFOCache(page); 068 } 069 070 @Override 071 public void invalidateCacheOnContentReactionChanged(Page page, Content content) throws Exception 072 { 073 _foCommHelper.invalidateFOCache(page); 074 } 075 076 @Override 077 public void invalidateCacheOnContentDeletion(Site site, String contentId) throws Exception 078 { 079 _foCommHelper.invalidateFOCache(site); 080 } 081 082 @Override 083 public void invalidateCacheOnContentModification(Site site, Content content) throws Exception 084 { 085 _foCommHelper.invalidateFOCache(site); 086 } 087}