1 16 package org.springframework.webflow.context.portlet; 17 18 import java.util.Map ; 19 20 import javax.portlet.PortletContext; 21 import javax.portlet.PortletRequest; 22 import javax.portlet.PortletResponse; 23 import javax.portlet.PortletSession; 24 25 import org.springframework.core.style.ToStringCreator; 26 import org.springframework.webflow.context.ExternalContext; 27 import org.springframework.webflow.core.collection.LocalAttributeMap; 28 import org.springframework.webflow.core.collection.LocalParameterMap; 29 import org.springframework.webflow.core.collection.LocalSharedAttributeMap; 30 import org.springframework.webflow.core.collection.MutableAttributeMap; 31 import org.springframework.webflow.core.collection.ParameterMap; 32 import org.springframework.webflow.core.collection.SharedAttributeMap; 33 34 40 public class PortletExternalContext implements ExternalContext { 41 42 45 private PortletContext context; 46 47 50 private PortletRequest request; 51 52 55 private PortletResponse response; 56 57 63 public PortletExternalContext(PortletContext context, PortletRequest request, PortletResponse response) { 64 this.context = context; 65 this.request = request; 66 this.response = response; 67 } 68 69 public String getContextPath() { 70 return request.getContextPath(); 71 } 72 73 public String getDispatcherPath() { 74 return null; 75 } 76 77 public String getRequestPathInfo() { 78 return null; 79 } 80 81 public ParameterMap getRequestParameterMap() { 82 return new LocalParameterMap(new PortletRequestParameterMap(request)); 83 } 84 85 public MutableAttributeMap getRequestMap() { 86 return new LocalAttributeMap(new PortletRequestMap(request)); 87 } 88 89 public SharedAttributeMap getSessionMap() { 90 return new LocalSharedAttributeMap(new PortletSessionMap(request, PortletSession.PORTLET_SCOPE)); 91 } 92 93 public SharedAttributeMap getGlobalSessionMap() { 94 return new LocalSharedAttributeMap(new PortletSessionMap(request, PortletSession.APPLICATION_SCOPE)); 95 } 96 97 public SharedAttributeMap getApplicationMap() { 98 return new LocalSharedAttributeMap(new PortletContextMap(context)); 99 } 100 101 105 public MutableAttributeMap getUserInfoMap() { 106 Map userInfo = (Map )request.getAttribute(PortletRequest.USER_INFO); 107 if (userInfo != null) { 108 return new LocalAttributeMap(userInfo); 109 } else { 110 return null; 111 } 112 } 113 114 117 public PortletContext getContext() { 118 return context; 119 } 120 121 124 public PortletRequest getRequest() { 125 return request; 126 } 127 128 131 public PortletResponse getResponse() { 132 return response; 133 } 134 135 public String toString() { 136 return new ToStringCreator(this).append("requestParameterMap", getRequestParameterMap()).toString(); 137 } 138 } | Popular Tags |