1 17 18 19 20 package org.apache.lenya.cms.cocoon.transformation; 21 22 import org.apache.avalon.framework.configuration.Configurable; 23 import org.apache.avalon.framework.configuration.Configuration; 24 import org.apache.avalon.framework.configuration.ConfigurationException; 25 import org.apache.cocoon.transformation.AbstractDOMTransformer; 26 import org.apache.cocoon.environment.ObjectModelHelper; 27 import org.apache.cocoon.environment.Request; 28 import org.apache.excalibur.source.Source; 29 import org.w3c.dom.Document ; 30 31 32 public class IncludeTransformer extends AbstractDOMTransformer implements Configurable { 33 private String domain = "127.0.0.1"; 34 private String context = null; 35 private String publication = null; 36 37 44 public void configure(Configuration conf) throws ConfigurationException { 45 if (conf != null) { 46 publication = conf.getChild("publication").getAttribute("type"); 47 getLogger().debug("PUBLICATION TYPE: " + publication); 48 } else { 49 getLogger().error("Configuration is null"); 50 } 51 } 52 53 57 protected Document transform(Document doc) { 58 try { 59 Source input_source = this.resolver.resolveURI(""); 60 String sitemapPath = input_source.getURI(); 61 getLogger().debug("Absolute SITEMAP Directory: " + sitemapPath); 62 63 String href = this.parameters.getParameter("href", null); 64 65 if (href != null) { 66 getLogger().debug("Parameter href = " + href); 67 } else { 68 getLogger().debug("No Parameter"); 69 } 70 71 Request request = ObjectModelHelper.getRequest(objectModel); 72 73 String request_uri = request.getRequestURI(); 74 String sitemap_uri = request.getSitemapURI(); 75 getLogger().debug("REQUEST URI: " + request_uri); 76 getLogger().debug("SITEMAP URI: " + sitemap_uri); 77 78 context = request.getContextPath(); 79 80 String context_publication = context + "/" + publication; 81 int port = request.getServerPort(); 82 String cocoon_base_request = "http://" + domain + ":" + port + context_publication; 83 getLogger().debug("COCOON_BASE_REQUEST: " + cocoon_base_request); 84 85 if (href != null) { 86 return new org.apache.lenya.xml.XPSAssembler().assemble(doc, sitemapPath + href, 87 cocoon_base_request); 88 } else { 89 return new org.apache.lenya.xml.XPSAssembler().assemble(doc, 90 sitemapPath + sitemap_uri, cocoon_base_request); 91 } 92 } catch (Exception e) { 93 getLogger().error(".transform(): " + e, e); 94 } 95 96 return doc; 97 } 98 } 99 | Popular Tags |