1 16 package org.apache.cocoon.portal.tools.transformation; 17 18 import java.util.Iterator ; 19 import java.util.List ; 20 21 import org.apache.avalon.framework.configuration.Configuration; 22 import org.apache.avalon.framework.configuration.ConfigurationException; 23 import org.apache.avalon.framework.configuration.DefaultConfiguration; 24 import org.apache.avalon.framework.service.ServiceException; 25 import org.apache.cocoon.portal.tools.PortalToolCatalogue; 26 import org.apache.cocoon.portal.tools.PortalToolManager; 27 import org.apache.cocoon.transformation.I18nTransformer; 28 29 33 public class PortalToolsI18nTransformer extends I18nTransformer { 34 35 public static String ROLE = PortalToolsI18nTransformer.class.getName(); 36 37 40 public void configure(Configuration conf) throws ConfigurationException { 41 46 47 if (conf.getChild("catalogues").getAttribute("new", "no").equals("no")) { 48 super.configure(conf); 49 return; 50 } 51 DefaultConfiguration root = new DefaultConfiguration("root"); 52 DefaultConfiguration defconf = new DefaultConfiguration("catalogues"); 53 defconf.setAttribute("default", "default"); 54 root.addChild(defconf); 55 PortalToolManager ptm = null; 56 try { 57 ptm = (PortalToolManager) this.manager.lookup(PortalToolManager.ROLE); 58 List i18nc = ptm.getI18n(); 59 for(Iterator it = i18nc.iterator(); it.hasNext();) { 60 PortalToolCatalogue ptc = (PortalToolCatalogue) it.next(); 61 DefaultConfiguration catConf = new DefaultConfiguration("catalogue"); 62 catConf.setAttribute("id", ptc.getId()); 63 catConf.setAttribute("name", ptc.getName()); 64 catConf.setAttribute("location", ptc.getLocation()); 65 defconf.addChild(catConf); 66 } 67 super.configure(root); 68 } catch (ServiceException e) { 69 e.printStackTrace(); 70 } catch (ConfigurationException e) { 71 e.printStackTrace(); 72 } finally { 73 this.manager.release(ptm); 74 } 75 } 76 77 } 78 | Popular Tags |