cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r155906 - in cocoon/trunk/src/blocks/portal: java/org/apache/cocoon/portal/acting/URLAction.java samples/coplets/html/sitemap.xmap samples/sitemap.xmap
Date Wed, 02 Mar 2005 10:55:34 GMT
Author: cziegeler
Date: Wed Mar  2 02:55:32 2005
New Revision: 155906

URL: http://svn.apache.org/viewcvs?view=rev&rev=155906
Log:
Fix bug in url generation for application coplets

Added:
    cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java   (with
props)
Modified:
    cocoon/trunk/src/blocks/portal/samples/coplets/html/sitemap.xmap
    cocoon/trunk/src/blocks/portal/samples/sitemap.xmap

Added: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java?view=auto&rev=155906
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java (added)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java Wed
Mar  2 02:55:32 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.acting;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.acting.ServiceableAction;
+import org.apache.cocoon.environment.Redirector;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.util.NetUtils;
+
+/**
+ * This action builds correct urls. It uses the src parameter as the base url
+ * and adds all sitemap parameters as request parameters.
+ *
+ * @version $Id:$
+*/
+public class URLAction
+extends ServiceableAction
+implements ThreadSafe {
+
+    public Map act(Redirector redirector,
+                   SourceResolver resolver,
+                   Map objectModel,
+                   String source,
+                   Parameters par)
+    throws Exception {
+        if (this.getLogger().isDebugEnabled() ) {
+            this.getLogger().debug("BEGIN act resolver="+resolver+
+                                   ", objectModel="+objectModel+
+                                   ", source="+source+
+                                   ", par="+par);
+        }
+
+        StringBuffer buffer = new StringBuffer(source);
+        boolean hasParams = (source.indexOf('?') != -1);
+        final String[] names = par.getNames();
+        for( int i=0; i<names.length; i++ ) {
+            final String key = names[i];
+            final String value = par.getParameter(key);
+            if ( hasParams ) {
+                buffer.append('&');
+            } else {
+                buffer.append('?');
+                hasParams = true;
+            }
+            buffer.append(key);
+            buffer.append('=');
+            buffer.append(NetUtils.encode(value, "utf-8"));
+        }
+        final Map result = Collections.singletonMap("url", buffer.toString());
+        if (this.getLogger().isDebugEnabled() ) {
+            this.getLogger().debug("END act map={}");
+        }
+
+        return result;
+    }
+
+}

Propchange: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/URLAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/blocks/portal/samples/coplets/html/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/samples/coplets/html/sitemap.xmap?view=diff&r1=155905&r2=155906
==============================================================================
--- cocoon/trunk/src/blocks/portal/samples/coplets/html/sitemap.xmap (original)
+++ cocoon/trunk/src/blocks/portal/samples/coplets/html/sitemap.xmap Wed Mar  2 02:55:32 2005
@@ -14,7 +14,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-<!-- SVN $Id:$ -->
+<!-- SVN $Id$ -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
   <map:pipelines>
     <map:pipeline type="noncaching">	
@@ -32,7 +32,10 @@
       </map:match>
 
       <map:match pattern="application">
-        <map:generate src="{coplet:temporaryAttributes/application-uri}?copletid={coplet:#}"/>
+        <map:act type="portal-urlhelper" src="{coplet:temporaryAttributes/application-uri}">
+          <map:parameter name="copletid" value="{coplet:#}"/>
+          <map:generate src="{url}"/>
+        </map:act>
         <map:transform type="htmlroot">
           <map:parameter name="add-mode" value="false"/>
         </map:transform>

Modified: cocoon/trunk/src/blocks/portal/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/portal/samples/sitemap.xmap?view=diff&r1=155905&r2=155906
==============================================================================
--- cocoon/trunk/src/blocks/portal/samples/sitemap.xmap (original)
+++ cocoon/trunk/src/blocks/portal/samples/sitemap.xmap Wed Mar  2 02:55:32 2005
@@ -72,7 +72,10 @@
       <map:action src="org.apache.cocoon.portal.acting.BookmarkAction" name="portal-bookmark">
         <parameter name="src" value="resources/bookmarks.xml"/>
       </map:action>
-      <map:action src="org.apache.cocoon.portal.acting.PreparePortalAction" name="portal-prepare"/>
+      <map:action name="portal-prepare"
+                  src="org.apache.cocoon.portal.acting.PreparePortalAction"/>
+      <map:action name="portal-urlhelper"
+                  src="org.apache.cocoon.portal.acting.URLAction"/>
     </map:actions>
   </map:components>
 



Mime
View raw message