001/*
002 *  Copyright 2017 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.frontoffice;
017
018import java.util.HashMap;
019import java.util.Map;
020import java.util.Set;
021
022import org.apache.avalon.framework.component.Component;
023import org.apache.avalon.framework.configuration.Configuration;
024import org.apache.avalon.framework.configuration.ConfigurationException;
025import org.apache.avalon.framework.logger.AbstractLogEnabled;
026
027import org.ametys.runtime.plugin.ExtensionPoint;
028
029
030/**
031 * This extension point handle additional parameters for FO search service
032 */
033public class AdditionalParameterFOSearchExtensionPoint extends AbstractLogEnabled implements ExtensionPoint<Configuration>, Component
034{
035    /** The avalon role */
036    public static final String ROLE = AdditionalParameterFOSearchExtensionPoint.class.getName();
037    
038    private Map<String, Configuration> _extensions = new HashMap<>();
039    private Map<String, String> _pluginNames = new HashMap<>();
040    
041    public void addExtension(String id, String pluginName, String featureName, Configuration configuration) throws ConfigurationException
042    {
043        _extensions.put(id, configuration.getChild("parameters"));
044        _pluginNames.put(id, pluginName);
045    }
046    
047    public Configuration getExtension(String id)
048    {
049        return _extensions.get(id);
050    }
051    
052    public Set<String> getExtensionsIds()
053    {
054        return _extensions.keySet();
055    }
056    
057    public boolean hasExtension(String id)
058    {
059        return _extensions.containsKey(id);
060    }
061    
062    public void initializeExtensions() throws Exception
063    {
064        // nothing to do
065    }
066    
067    /**
068     * Get the plugin name of the extension
069     * @param id the id of the extension
070     * @return the plugin name
071     */
072    public String getPluginName(String id)
073    {
074        return _pluginNames.get(id);
075    }
076}