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