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.tagcloud.cache.service;
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.web.cache.pageelement.AbstractSimplePageElementCachePolicy;
025import org.ametys.web.cache.pageelement.PageElementCachePolicy;
026
027/**
028 * {@link PageElementCachePolicy} for the tag cloud service.
029 */
030public class TagCloudServiceCachePolicy extends AbstractSimplePageElementCachePolicy
031{
032    
033    /** The tag cloud service ID. */
034    public static final String SERVICE_TAG_CLOUD_ID = "org.ametys.plugins.tagcloud.services.Tags";
035    
036    @Override
037    public Set<String> getPageElementTypes()
038    {
039        return Collections.singleton("SERVICE:" + SERVICE_TAG_CLOUD_ID);
040    }
041    
042    @Override
043    protected List<String> _getRemovingCacheEventIds(String workspace)
044    {
045        if ("default".equals(workspace))
046        {
047            return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED,
048                                 ObservationConstants.EVENT_CONTENT_DELETED,
049                                 ObservationConstants.EVENT_CONTENT_TAGGED,
050                                 ObservationConstants.EVENT_TAG_UPDATED,
051                                 ObservationConstants.EVENT_TAG_DELETED,
052                                 org.ametys.web.ObservationConstants.EVENT_PAGE_CHANGED,
053                                 org.ametys.web.ObservationConstants.EVENT_PAGE_MOVED,
054                                 org.ametys.web.ObservationConstants.EVENT_PAGE_DELETED
055                                 );
056        }
057        else if ("live".equals(workspace))
058        {
059            return Arrays.asList(ObservationConstants.EVENT_CONTENT_ADDED,
060                                 ObservationConstants.EVENT_CONTENT_DELETED,
061                                 ObservationConstants.EVENT_CONTENT_TAGGED,
062                                 ObservationConstants.EVENT_TAG_UPDATED,
063                                 ObservationConstants.EVENT_TAG_DELETED,
064                                 org.ametys.web.ObservationConstants.EVENT_PAGE_CHANGED,
065                                 org.ametys.web.ObservationConstants.EVENT_PAGE_MOVED,
066                                 org.ametys.web.ObservationConstants.EVENT_PAGE_DELETED
067                                 );
068        }
069        
070        return Collections.emptyList();
071    }
072    
073}