1 15 package org.apache.tapestry.portlet; 16 17 import java.util.List ; 18 import java.util.Locale ; 19 20 import javax.portlet.PortletRequest; 21 import javax.portlet.PortletSession; 22 23 import org.apache.hivemind.util.Defense; 24 import org.apache.tapestry.describe.DescriptionReceiver; 25 import org.apache.tapestry.web.WebRequest; 26 import org.apache.tapestry.web.WebSession; 27 import org.apache.tapestry.web.WebUtils; 28 29 36 public class PortletWebRequest implements WebRequest 37 { 38 private final PortletRequest _portletRequest; 39 40 private WebSession _webSession; 41 42 public PortletWebRequest(PortletRequest portletRequest) 43 { 44 Defense.notNull(portletRequest, "portletRequest"); 45 46 _portletRequest = portletRequest; 47 } 48 49 public List getParameterNames() 50 { 51 return WebUtils.toSortedList(_portletRequest.getParameterNames()); 52 } 53 54 public String getParameterValue(String parameterName) 55 { 56 return _portletRequest.getParameter(parameterName); 57 } 58 59 public String [] getParameterValues(String parameterName) 60 { 61 return _portletRequest.getParameterValues(parameterName); 62 } 63 64 public String getContextPath() 65 { 66 return _portletRequest.getContextPath(); 67 } 68 69 public WebSession getSession(boolean create) 70 { 71 if (_webSession != null) 72 return _webSession; 73 74 PortletSession session = _portletRequest.getPortletSession(create); 75 76 if (session != null) 77 _webSession = new PortletWebSession(session); 78 79 return _webSession; 80 } 81 82 public String getScheme() 83 { 84 return _portletRequest.getScheme(); 85 } 86 87 public String getServerName() 88 { 89 return _portletRequest.getServerName(); 90 } 91 92 public int getServerPort() 93 { 94 return _portletRequest.getServerPort(); 95 } 96 97 100 101 public String getRequestURI() 102 { 103 return "<PortletRequest>"; 104 } 105 106 public void forward(String URL) 107 { 108 unsupported("forward"); 109 } 110 111 public String getActivationPath() 112 { 113 return ""; 114 } 115 116 public List getAttributeNames() 117 { 118 return WebUtils.toSortedList(_portletRequest.getAttributeNames()); 119 } 120 121 public Object getAttribute(String name) 122 { 123 return _portletRequest.getAttribute(name); 124 } 125 126 public void setAttribute(String name, Object attribute) 127 { 128 if (attribute == null) 129 _portletRequest.removeAttribute(name); 130 else 131 _portletRequest.setAttribute(name, attribute); 132 } 133 134 protected final void unsupported(String methodName) 135 { 136 throw new UnsupportedOperationException (PortletMessages.unsupportedMethod(methodName)); 137 } 138 139 public void describeTo(DescriptionReceiver receiver) 140 { 141 receiver.describeAlternate(_portletRequest); 142 } 143 144 public Locale getLocale() 145 { 146 return _portletRequest.getLocale(); 147 } 148 149 public String getHeader(String name) 150 { 151 unsupported("getHeader"); 152 153 return null; 154 } 155 } | Popular Tags |