1 16 19 20 package org.apache.pluto.portalImpl.servlet; 21 22 import java.util.Collections ; 23 import java.util.Enumeration ; 24 import java.util.HashMap ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 import org.apache.pluto.om.window.PortletWindow; 29 import org.apache.pluto.portalImpl.core.PortalControlParameter; 30 import org.apache.pluto.portalImpl.core.PortalEnvironment; 31 32 public class ServletRequestImpl extends javax.servlet.http.HttpServletRequestWrapper 33 { 34 35 PortalControlParameter control = null; 36 PortletWindow portletWindow = null; 37 38 public ServletRequestImpl(javax.servlet.http.HttpServletRequest servletRequest, PortletWindow window) 39 { 40 super(servletRequest); 41 42 this.portletWindow = window; 43 control = new PortalControlParameter( 44 PortalEnvironment.getPortalEnvironment(servletRequest).getRequestedPortalURL()); 45 46 } 47 48 50 public java.lang.String getContentType() 51 { 52 String contentType = super.getContentType(); 53 return contentType; 54 } 55 56 58 public String getParameter(String name) 59 { 60 String [] values=(String []) this.getParameterMap().get(name); 61 if (values!=null) { 62 return values[0]; 63 } 64 return null; 65 } 66 67 public Map getParameterMap() 68 { 69 Map portletParameters = new HashMap (); 71 72 Iterator iterator = control.getRenderParamNames(portletWindow); 73 while (iterator.hasNext()) 74 { 75 String name = (String )iterator.next(); 76 77 String [] values = control.getRenderParamValues(portletWindow, name); 78 79 portletParameters.put(name, values ); 80 81 } 82 83 String pid = control.getPIDValue(); 85 String wid = portletWindow.getId().toString(); 86 if (pid.equals(wid)) { 87 for (Enumeration parameters = super.getParameterNames(); parameters.hasMoreElements();) { 88 String paramName = (String )parameters.nextElement(); 89 String [] paramValues = super.getParameterValues(paramName); 90 String [] values = (String [])portletParameters.get(paramName); 91 92 if (values != null) { 93 String [] temp = new String [paramValues.length + values.length]; 94 System.arraycopy(paramValues, 0, temp, 0, paramValues.length); 95 System.arraycopy(values, 0, temp, paramValues.length, values.length); 96 paramValues = temp; 97 } 98 portletParameters.put(paramName, paramValues); 99 } 100 } 101 102 return Collections.unmodifiableMap(portletParameters); 103 } 104 105 public Enumeration getParameterNames() 106 { 107 return Collections.enumeration(this.getParameterMap().keySet()); 108 } 109 110 public String [] getParameterValues(String name) 111 { 112 return (String []) this.getParameterMap().get(name); 113 } 114 115 } 116 117 118 | Popular Tags |