You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/06/25 15:00:09 UTC

svn commit: r550480 - in /lenya/trunk/src: java/org/apache/lenya/cms/cocoon/components/modules/input/ modules-core/linking/config/cocoon-xconf/ modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ webapp/lenya/config/coco...

Author: andreas
Date: Mon Jun 25 06:00:08 2007
New Revision: 550480

URL: http://svn.apache.org/viewvc?view=rev&rev=550480
Log:
Consolidated BaseURLModule and ProxyUrlModule to ProxyModule

Added:
    lenya/trunk/src/modules-core/linking/config/cocoon-xconf/proxy-url.xconf
      - copied, changed from r546514, lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/proxy-url.xconf
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java
      - copied, changed from r550470, lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/BaseURLModule.java
Removed:
    lenya/trunk/src/java/org/apache/lenya/cms/cocoon/components/modules/input/ProxyUrlModule.java
    lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/BaseURLModule.java
    lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/base-url.xconf
    lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/proxy-url.xconf

Copied: lenya/trunk/src/modules-core/linking/config/cocoon-xconf/proxy-url.xconf (from r546514, lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/proxy-url.xconf)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/config/cocoon-xconf/proxy-url.xconf?view=diff&rev=550480&p1=lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/proxy-url.xconf&r1=546514&p2=lenya/trunk/src/modules-core/linking/config/cocoon-xconf/proxy-url.xconf&r2=550480
==============================================================================
--- lenya/trunk/src/webapp/lenya/config/cocoon-xconf/input-modules/proxy-url.xconf (original)
+++ lenya/trunk/src/modules-core/linking/config/cocoon-xconf/proxy-url.xconf Mon Jun 25 06:00:08 2007
@@ -21,7 +21,7 @@
     This file defines the publication specific use-cases
 -->
 
-  <xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'proxy-url']">
-    <component-instance name="proxy-url" logger="sitemap.modules.input.proxy-url"
-      class="org.apache.lenya.cms.cocoon.components.modules.input.ProxyUrlModule"/>
+  <xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'proxy']">
+    <component-instance name="proxy" logger="sitemap.modules.input.proxy"
+      class="org.apache.lenya.cms.cocoon.components.modules.input.ProxyModule"/>
   </xconf>

Copied: lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java (from r550470, lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/BaseURLModule.java)
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java?view=diff&rev=550480&p1=lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/BaseURLModule.java&r1=550470&p2=lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java&r2=550480
==============================================================================
--- lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/BaseURLModule.java (original)
+++ lenya/trunk/src/modules-core/linking/java/src/org/apache/lenya/cms/cocoon/components/modules/input/ProxyModule.java Mon Jun 25 06:00:08 2007
@@ -17,10 +17,8 @@
  */
 package org.apache.lenya.cms.cocoon.components.modules.input;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -33,35 +31,22 @@
 import org.apache.cocoon.environment.Request;
 import org.apache.lenya.cms.linking.LinkRewriter;
 import org.apache.lenya.cms.linking.OutgoingLinkRewriter;
-import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
-import org.apache.lenya.cms.publication.Proxy;
-import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.RepositoryUtil;
 import org.apache.lenya.cms.repository.Session;
 
 /**
  * Input module for getting the base URL which may be prepended to internal URLs
- * to construct links. The base-url contains no trailing slash.
+ * to construct links. The functionality corresponds to the
+ * {@link org.apache.lenya.cms.cocoon.transformation.ProxyTransformer} with one
+ * exception: If the <em>webappUrl</em> parameter is an empty string, the root
+ * proxy URL (or the context prefix, resp.) is returned.
  * 
  * <p>
- * Usage: <code>{base-url:{pubid}:{area}}</code>
+ * Usage: <code>{proxy:{webappUrl}}</code>
  * </p>
- * 
- * <p>
- * If the publication uses proxying, the base URL is the proxy URL defined in
- * the file
- * {@link org.apache.lenya.cms.publication.PublicationConfiguration#CONFIGURATION_FILE}.
- * If no proxying is used, the result will be {context-path}/{pub-id}/{area}.
- * </p>
- * <p>
- * Both <code>pubid</code> and <code>area</code> can be empty strings. In
- * this case, the context path or the root proxy of the publication, resp., is returned.
- * </p>
- * 
  */
-public class BaseURLModule extends AbstractInputModule implements Serviceable {
+public class ProxyModule extends AbstractInputModule implements Serviceable {
 
     private ServiceManager manager;
 
@@ -73,44 +58,36 @@
     public Object getAttribute(String name, Configuration modeConf, Map objectModel)
             throws ConfigurationException {
 
-        // Get parameters
-        final String[] attributes = name.split(":", -1);
-
-        if (attributes.length < 2) {
-            throw new ConfigurationException("Invalid number of parameters: " + attributes.length
-                    + ". Expected pubid, area, [ssl].");
-        }
-
+        final String webappUrl = name;
         Request request = ObjectModelHelper.getRequest(objectModel);
 
-        final String pubId = attributes[0];
-        final String area = attributes[1];
-
         String value = null;
         try {
-
-            if (pubId.equals("") && area.equals("")) {
+            if (webappUrl.equals("")) {
                 value = rewrite(request, "/");
                 if (value.endsWith("/")) {
                     value = value.substring(0, value.length() - 1);
                 }
             } else {
-                value = rewrite(request, "/" + pubId + "/" + area);
+                value = rewrite(request, webappUrl);
             }
-            
+        } catch (ConfigurationException e) {
+            throw e;
         } catch (Exception e) {
             throw new ConfigurationException("Obtaining value for [" + name + "] failed: ", e);
         }
         return value;
     }
 
-    protected String rewrite(Request request, String url) throws RepositoryException {
-        String value;
+    protected String rewrite(Request request, String url) throws RepositoryException,
+            ConfigurationException {
         Session session = RepositoryUtil.getSession(this.manager, request);
         LinkRewriter rewriter = new OutgoingLinkRewriter(this.manager, session, request
                 .getRequestURI(), false);
-        value = rewriter.rewrite(url);
-        return value;
+        if (!rewriter.matches(url)) {
+            throw new ConfigurationException("The URL [" + url + "] can't be rewritten!");
+        }
+        return rewriter.rewrite(url);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org