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