1 16 package org.apache.cocoon.portal.acting; 17 18 import java.util.Collections ; 19 import java.util.Map ; 20 21 import org.apache.avalon.framework.parameters.Parameters; 22 import org.apache.avalon.framework.thread.ThreadSafe; 23 import org.apache.cocoon.acting.ServiceableAction; 24 import org.apache.cocoon.environment.Redirector; 25 import org.apache.cocoon.environment.SourceResolver; 26 import org.apache.cocoon.util.NetUtils; 27 28 34 public class URLAction 35 extends ServiceableAction 36 implements ThreadSafe { 37 38 public Map act(Redirector redirector, 39 SourceResolver resolver, 40 Map objectModel, 41 String source, 42 Parameters par) 43 throws Exception { 44 if (this.getLogger().isDebugEnabled() ) { 45 this.getLogger().debug("BEGIN act resolver="+resolver+ 46 ", objectModel="+objectModel+ 47 ", source="+source+ 48 ", par="+par); 49 } 50 51 StringBuffer buffer = new StringBuffer (source); 52 boolean hasParams = (source.indexOf('?') != -1); 53 final String [] names = par.getNames(); 54 for( int i=0; i<names.length; i++ ) { 55 final String key = names[i]; 56 final String value = par.getParameter(key); 57 if ( hasParams ) { 58 buffer.append('&'); 59 } else { 60 buffer.append('?'); 61 hasParams = true; 62 } 63 buffer.append(key); 64 buffer.append('='); 65 buffer.append(NetUtils.encode(value, "utf-8")); 66 } 67 final Map result = Collections.singletonMap("url", buffer.toString()); 68 if (this.getLogger().isDebugEnabled() ) { 69 this.getLogger().debug("END act map={}"); 70 } 71 72 return result; 73 } 74 75 } 76 | Popular Tags |