001/*
002 *  Copyright 2015 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.odfweb.cachepolicy;
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 insert program service.
029 */
030public class InsertProgramServiceCachePolicy extends AbstractSimplePageElementCachePolicy
031{
032
033    /** The insert program service ID. */
034    public static final String SERVICE_INSERT_PROGRAM_ID = "org.ametys.odf.service.InsertProgram";
035    
036    @Override
037    public Set<String> getPageElementTypes()
038    {
039        return Collections.singleton("SERVICE:" + SERVICE_INSERT_PROGRAM_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_MODIFIED, ObservationConstants.EVENT_CONTENT_DELETED);
048        }
049        else if ("live".equals(workspace))
050        {
051            return Arrays.asList(ObservationConstants.EVENT_CONTENT_VALIDATED,
052                                 ObservationConstants.EVENT_CONTENT_DELETED,
053                                 ObservationConstants.EVENT_CONTENT_UNTAG_LIVE);
054        }
055        
056        return Collections.emptyList();
057    }
058
059}