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.cms.source;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import org.ametys.core.source.ViewSelector;
022
023/**
024 * CMS implementation of {@link ViewSelector}.
025 * First looks the wanted file in context://WEB-INF/param/view/path_to_file
026 * If it's not present, it will look in the current plugin, then in cms plugin
027 */
028public class DefaultViewSelector extends org.ametys.core.source.DefaultViewSelector
029{
030    @Override
031    protected List<String> _getDefaultSourceURIs(String pluginName, String filePath)
032    {
033        List<String> locations = new ArrayList<>();
034        
035        // For legacy, look in CMS plugin
036        if (!"cms".equals(pluginName))
037        {
038            locations.add("plugin:cms://" + filePath);
039        }
040        
041        locations.addAll(super._getDefaultSourceURIs(pluginName, filePath));
042        
043        return locations;
044    }
045}