001/* 002 * Copyright 2018 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.frontoffice.search; 017 018import java.util.Arrays; 019import java.util.Collections; 020import java.util.List; 021import java.util.Set; 022 023import org.ametys.cms.ObservationConstants; 024import org.ametys.plugins.repository.RepositoryConstants; 025import org.ametys.web.WebConstants; 026import org.ametys.web.cache.pageelement.AbstractSimplePageElementCachePolicy; 027import org.ametys.web.cache.pageelement.PageElementCachePolicy; 028 029/** 030 * {@link PageElementCachePolicy} for the front search service.<br> 031 */ 032public class SearchServiceCachePolicy extends AbstractSimplePageElementCachePolicy 033{ 034 @Override 035 public Set<String> getPageElementTypes() 036 { 037 return Collections.singleton("SERVICE:" + SearchService.ROLE); 038 } 039 040 @Override 041 protected List<String> _getRemovingCacheEventIds(String workspace) 042 { 043 if (RepositoryConstants.DEFAULT_WORKSPACE.equals(workspace)) 044 { 045 return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED, 046 ObservationConstants.EVENT_CONTENT_MODIFIED, 047 ObservationConstants.EVENT_CONTENT_TAGGED, 048 ObservationConstants.EVENT_CONTENT_DELETED, 049 org.ametys.web.ObservationConstants.EVENT_PAGE_ADDED, 050 org.ametys.web.ObservationConstants.EVENT_PAGE_CHANGED, 051 org.ametys.web.ObservationConstants.EVENT_PAGE_UPDATED, 052 org.ametys.web.ObservationConstants.EVENT_PAGE_RENAMED, 053 org.ametys.web.ObservationConstants.EVENT_PAGE_MOVED, 054 org.ametys.web.ObservationConstants.EVENT_PAGE_DELETED, 055 org.ametys.web.ObservationConstants.EVENT_ZONEITEM_DELETED, 056 org.ametys.web.ObservationConstants.EVENT_ZONEITEM_MODIFIED, 057 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_CREATED, 058 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_UPDATED, 059 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_RENAMED, 060 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_MOVED, 061 org.ametys.plugins.explorer.ObservationConstants.EVENT_COLLECTION_RENAMED, 062 org.ametys.plugins.explorer.ObservationConstants.EVENT_COLLECTION_DELETED, 063 ObservationConstants.EVENT_TAG_ADDED, 064 ObservationConstants.EVENT_TAG_UPDATED, 065 ObservationConstants.EVENT_TAG_DELETED, 066 org.ametys.core.ObservationConstants.EVENT_ACL_UPDATED); 067 } 068 else if (WebConstants.LIVE_WORKSPACE.equals(workspace)) 069 { 070 return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED, 071 ObservationConstants.EVENT_CONTENT_VALIDATED, 072 ObservationConstants.EVENT_CONTENT_TAGGED, 073 ObservationConstants.EVENT_CONTENT_DELETED, 074 ObservationConstants.EVENT_CONTENT_UNTAG_LIVE, 075 org.ametys.web.ObservationConstants.EVENT_PAGE_ADDED, 076 org.ametys.web.ObservationConstants.EVENT_PAGE_CHANGED, 077 org.ametys.web.ObservationConstants.EVENT_PAGE_UPDATED, 078 org.ametys.web.ObservationConstants.EVENT_PAGE_RENAMED, 079 org.ametys.web.ObservationConstants.EVENT_PAGE_MOVED, 080 org.ametys.web.ObservationConstants.EVENT_PAGE_DELETED, 081 org.ametys.web.ObservationConstants.EVENT_ZONEITEM_DELETED, 082 org.ametys.web.ObservationConstants.EVENT_ZONEITEM_MODIFIED, 083 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_CREATED, 084 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_UPDATED, 085 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_RENAMED, 086 org.ametys.plugins.explorer.ObservationConstants.EVENT_RESOURCE_MOVED, 087 org.ametys.plugins.explorer.ObservationConstants.EVENT_COLLECTION_RENAMED, 088 org.ametys.plugins.explorer.ObservationConstants.EVENT_COLLECTION_DELETED, 089 ObservationConstants.EVENT_TAG_ADDED, 090 ObservationConstants.EVENT_TAG_UPDATED, 091 ObservationConstants.EVENT_TAG_DELETED, 092 org.ametys.core.ObservationConstants.EVENT_ACL_UPDATED); 093 094 } 095 096 return Collections.emptyList(); 097 } 098}