001/*
002 *  Copyright 2019 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.source;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import org.ametys.odf.source.DefaultODFView;
022
023/**
024 * This implementation of a {@link ODFWebView} looks first in the directory skin://stylesheets/catalog/ then defaults to {@link DefaultODFView}.
025 */
026public class ODFWebView extends DefaultODFView
027{
028    @Override
029    protected List<String> getLocations(String pluginName, String filePath)
030    {
031        List<String> locations = new ArrayList<>();
032        
033        // First look for the file in the skin.
034        locations.add("skin://" + filePath);
035        
036        // If it was not found, look in the default locations.
037        locations.addAll(super.getLocations(pluginName, filePath));
038        
039        return locations;
040    }
041    
042    @Override
043    protected List<String> _getDefaultSourceURIs(String pluginName, String filePath)
044    {
045        List<String> locations = new ArrayList<>();
046        
047        if (!"odf-web".equals(pluginName))
048        {
049            // For legacy, then look in the web plugin.
050            locations.add("plugin:odf-web://" + filePath);
051        }
052        
053        locations.addAll(super._getDefaultSourceURIs(pluginName, filePath));
054        
055        return locations;
056    }
057}