1 16 package org.apache.cocoon.environment.portlet; 17 18 import javax.portlet.ActionRequest; 19 import javax.portlet.ActionResponse; 20 import javax.portlet.PortletContext; 21 import javax.portlet.PortletRequest; 22 import javax.portlet.PortletResponse; 23 import javax.portlet.RenderRequest; 24 import javax.portlet.RenderResponse; 25 26 import java.util.Map ; 27 28 39 public final class PortletObjectModelHelper { 40 41 42 public final static String RENDER_REQUEST_OBJECT = "render-request"; 43 44 45 public final static String ACTION_REQUEST_OBJECT = "action-request"; 46 47 48 public final static String RENDER_RESPONSE_OBJECT = "render-response"; 49 50 51 public final static String ACTION_RESPONSE_OBJECT = "action-response"; 52 53 54 public static final String PORTLET_REQUEST_OBJECT = "portlet-request"; 55 56 57 public static final String PORTLET_RESPONSE_OBJECT = "portlet-response"; 58 59 60 public static final String PORTLET_CONTEXT_OBJECT = "portlet-context"; 61 62 private PortletObjectModelHelper() { 63 } 65 66 public static final RenderRequest getRenderRequest(Map objectModel) { 67 return (RenderRequest) objectModel.get(RENDER_REQUEST_OBJECT); 68 } 69 70 public static final RenderResponse getRenderResponse(Map objectModel) { 71 return (RenderResponse) objectModel.get(RENDER_RESPONSE_OBJECT); 72 } 73 74 public static final ActionRequest getActionRequest(Map objectModel) { 75 return (ActionRequest) objectModel.get(ACTION_REQUEST_OBJECT); 76 } 77 78 public static final ActionResponse getActionResponse(Map objectModel) { 79 return (ActionResponse) objectModel.get(ACTION_RESPONSE_OBJECT); 80 } 81 82 public static final PortletRequest getPortletRequest(Map objectModel) { 83 return (PortletRequest) objectModel.get(PORTLET_REQUEST_OBJECT); 84 } 85 86 public static final PortletResponse getPortletResponse(Map objectModel) { 87 return (PortletResponse) objectModel.get(PORTLET_RESPONSE_OBJECT); 88 } 89 90 public static final PortletContext getPortletContext(Map objectModel) { 91 return (PortletContext) objectModel.get(PORTLET_CONTEXT_OBJECT); 92 } 93 94 public static final void setPortletRequest(Map objectModel, PortletRequest object) { 95 if (objectModel.get(PORTLET_REQUEST_OBJECT) != null) { 96 throw new IllegalStateException ("PortletRequest has been set already"); 97 } 98 objectModel.put(PORTLET_REQUEST_OBJECT, object); 99 if (object instanceof ActionRequest) { 100 objectModel.put(ACTION_REQUEST_OBJECT, object); 101 } 102 if (object instanceof RenderRequest) { 103 objectModel.put(RENDER_REQUEST_OBJECT, object); 104 } 105 } 106 107 public static final void setPortletResponse(Map objectModel, PortletResponse object) { 108 if (objectModel.get(PORTLET_RESPONSE_OBJECT) != null) { 109 throw new IllegalStateException ("PortletResponse has been set already"); 110 } 111 objectModel.put(PORTLET_RESPONSE_OBJECT, object); 112 if (object instanceof ActionResponse) { 113 objectModel.put(ACTION_RESPONSE_OBJECT, object); 114 } 115 if (object instanceof RenderResponse) { 116 objectModel.put(RENDER_RESPONSE_OBJECT, object); 117 } 118 } 119 120 public static final void setPortletContext(Map objectModel, PortletContext object) { 121 if (objectModel.get(PORTLET_CONTEXT_OBJECT) != null) { 122 throw new IllegalStateException ("PortletContext has been set already"); 123 } 124 objectModel.put(PORTLET_CONTEXT_OBJECT, object); 125 } 126 } 127 | Popular Tags |