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.web.site;
017
018import org.apache.avalon.framework.configuration.Configuration;
019import org.apache.avalon.framework.configuration.ConfigurationException;
020import org.apache.avalon.framework.service.ServiceManager;
021
022import org.ametys.runtime.model.ElementDefinition;
023import org.ametys.runtime.model.ElementDefinitionParser;
024import org.ametys.runtime.model.Enumerator;
025import org.ametys.runtime.model.type.ModelItemType;
026import org.ametys.runtime.parameter.Validator;
027import org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint;
028import org.ametys.runtime.plugin.component.ThreadSafeComponentManager;
029
030/**
031 * Parser for Site parameter.
032 */
033public class SiteParameterParser extends ElementDefinitionParser
034{
035    /**
036     * Creates a site parameter parser.
037     * @param elementTypeExtensionPoint the extension point to use to get available element types
038     * @param enumeratorManager the enumerator component manager.
039     * @param validatorManager the validator component manager.
040     */
041    public SiteParameterParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> elementTypeExtensionPoint,
042            ThreadSafeComponentManager<Enumerator> enumeratorManager, ThreadSafeComponentManager<Validator> validatorManager)
043    {
044        super(elementTypeExtensionPoint, enumeratorManager, validatorManager);
045    }
046    
047    @Override
048    protected String _getNameConfigurationAttribute()
049    {
050        return "id";
051    }
052    
053    /**
054     * Parses a site parameter from a XML configuration.
055     * A site parameter has no model at parsing. Parameters are copied for each model after parsing  
056     * @param serviceManager the service manager
057     * @param pluginName the plugin name declaring this parameter.
058     * @param parameterConfig the XML configuration of the parameter.
059     * @return the parsed parameter.
060     * @throws ConfigurationException if the configuration is not valid.
061     */
062    public ElementDefinition parse(ServiceManager serviceManager, String pluginName, Configuration parameterConfig) throws ConfigurationException
063    {
064        return super.parse(serviceManager, pluginName, parameterConfig, null, null);
065    }
066}