001/* 002 * Copyright 2012 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.plugins.blog.cachepolicy; 017 018import java.util.Arrays; 019import java.util.Collections; 020import java.util.HashSet; 021import java.util.List; 022import java.util.Set; 023 024import org.ametys.cms.ObservationConstants; 025import org.ametys.plugins.blog.BlogObservationConstants; 026 027/** 028 * Cache policy for the sitemap, handling blog virtual pages linked with contents. 029 */ 030public class BlogVirtualPagesWithCommentsCachePolicy extends BlogVirtualPagesCachePolicy 031{ 032 033 private static final Set<String> _TYPES = new HashSet<>(); 034 static 035 { 036 // Used for the "content" type and services which display comments. 037 _TYPES.add("CONTENT"); 038 _TYPES.add("SERVICE:org.ametys.blog.service.PostsService"); 039 _TYPES.add("SERVICE:org.ametys.plugins.blog.service.FilteredPostsService"); 040 } 041 042 @Override 043 public Set<String> getPageElementTypes() 044 { 045 return _TYPES; 046 } 047 048 @Override 049 protected List<String> _getRemovingCacheEventIds(String workspace) 050 { 051 if ("default".equals(workspace)) 052 { 053 return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED, 054 ObservationConstants.EVENT_CONTENT_MODIFIED, 055 ObservationConstants.EVENT_CONTENT_DELETING, 056 BlogObservationConstants.EVENT_FUTURE_CONTENT_VISIBLE, 057 ObservationConstants.EVENT_CONTENT_COMMENT_VALIDATED, 058 ObservationConstants.EVENT_CONTENT_COMMENT_UNVALIDATED); 059 } 060 else if ("live".equals(workspace)) 061 { 062 return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED, 063 ObservationConstants.EVENT_CONTENT_VALIDATED, 064 ObservationConstants.EVENT_CONTENT_DELETING, 065 BlogObservationConstants.EVENT_FUTURE_CONTENT_VISIBLE, 066 ObservationConstants.EVENT_CONTENT_COMMENT_VALIDATED, 067 ObservationConstants.EVENT_CONTENT_COMMENT_UNVALIDATED, 068 ObservationConstants.EVENT_CONTENT_UNTAG_LIVE); 069 } 070 071 return Collections.emptyList(); 072 } 073 074}