1 9 package org.jboss.portlet; 10 11 import javax.portlet.PortletURL; 12 13 import org.jboss.portal.core.output.AuthenticateResult; 14 import org.jboss.portal.server.output.StreamResult; 15 import org.jboss.portal.portlet.PortletUtils; 16 import org.jboss.portal.portlet.impl.ActionResponseImpl; 17 import org.jboss.portal.server.PortalRequest; 18 import org.jboss.portal.server.PortalResponse; 19 import org.jboss.portal.server.ServerURL; 20 import org.jboss.portal.server.Window; 21 import org.jboss.portal.server.WindowContext; 22 import org.jboss.portal.server.output.NoResult; 23 import org.jboss.portal.server.output.StreamResult; 24 import org.jboss.portal.server.util.Properties; 25 26 30 public class JBossActionResponse extends ActionResponseImpl 31 { 32 33 public JBossActionResponse( 34 WindowContext windowCtx, 35 Window window, 36 PortalRequest req, 37 PortalResponse resp, 38 Properties properties) 39 { 40 super(windowCtx, window, req, resp, properties); 41 } 42 43 50 public void sendAuthenticate() throws IllegalStateException 51 { 52 if (result instanceof NoResult || result instanceof AuthenticateResult) 53 { 54 if (result instanceof NoResult) 55 { 56 ServerURL url = PortletUtils.createWindowActionURL(resp, window); 57 result = new AuthenticateResult(portletWindowContext, url); 58 } 59 } 60 else 61 { 62 throw new IllegalStateException ("Cannot call send authenticate"); 63 } 64 } 65 66 public void sendBytes(String contentType, byte[] bytes) 67 { 68 if (result instanceof NoResult) 69 { 70 result = new StreamResult(portletWindowContext, contentType, bytes); 71 } 72 else 73 { 74 throw new IllegalStateException ("Cannot call send bytes"); 75 } 76 } 77 78 81 public PortletURL createRenderURL() 82 { 83 return PortletUtils.createRenderURL(resp, window, req.getContentType()); 84 } 85 86 89 public PortletURL createActionURL() 90 { 91 return PortletUtils.createActionURL(resp, window, req.getContentType()); 92 } 93 94 97 public String createAbsoluteURL(PortletURL url) 98 { 99 return JBossRenderResponse.createAbsoluteURL(resp, url); 100 } 101 } 102 | Popular Tags |