001/* 002 * Copyright 2024 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.cms.properties.section.technical; 017 018import org.apache.avalon.framework.configuration.Configurable; 019import org.apache.avalon.framework.configuration.Configuration; 020import org.apache.avalon.framework.configuration.ConfigurationException; 021 022import org.ametys.runtime.plugin.component.PluginAware; 023 024/** 025 * Abstract implementation of {@link TechnicalItem} to make priority and XSL configurable. 026 */ 027public abstract class AbstractTechnicalItem implements TechnicalItem, Configurable, PluginAware 028{ 029 private String _id; 030 private int _priority; 031 private String _xslt; 032 033 public void configure(Configuration configuration) throws ConfigurationException 034 { 035 _priority = configuration.getChild("priority").getValueAsInteger(Integer.MAX_VALUE); 036 _xslt = configuration.getChild("xslt").getValue(_getDefaultXSLT()); 037 if (_xslt == null) 038 { 039 throw new ConfigurationException("No default XSLT defined"); 040 } 041 } 042 043 public void setPluginInfo(String pluginName, String featureName, String id) 044 { 045 _id = id; 046 } 047 048 public String getId() 049 { 050 return _id; 051 } 052 053 public int getPriority() 054 { 055 return _priority; 056 } 057 058 public String getXSLT() 059 { 060 return _xslt; 061 } 062 063 /** 064 * The default XSL if not defined in the configuration. 065 * Not mandatory to implement this method but if there is not XSLT configured for the section, the loading will failed. 066 * @return The default XSL path 067 */ 068 protected String _getDefaultXSLT() 069 { 070 return null; 071 } 072}