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