1 9 package org.jboss.portal.portlet.impl; 10 11 import java.util.Map ; 12 13 import javax.portlet.PortletMode; 14 import javax.portlet.PortletModeException; 15 import javax.portlet.PortletSecurityException; 16 import javax.portlet.PortletURL; 17 import javax.portlet.WindowState; 18 import javax.portlet.WindowStateException; 19 20 import org.jboss.portal.server.PortalResponse; 21 import org.jboss.portal.server.Window; 22 import org.jboss.portal.server.WindowURL; 23 import org.jboss.portal.server.plugins.mode.Mode; 24 import org.jboss.portal.server.util.Parameters; 25 26 30 public class PortletURLImpl implements PortletURL 31 { 32 33 private WindowURL windowURL; 34 private Window window; 35 private String contentType; 36 private PortalResponse resp; 37 38 public PortletURLImpl(WindowURL windowURL, 39 Window window, 40 String contentType, 41 PortalResponse resp) 42 { 43 this.windowURL = windowURL; 44 this.window = window; 45 this.contentType = contentType; 46 this.resp = resp; 47 } 48 49 public void setWindowState(WindowState windowState) throws WindowStateException 50 { 51 org.jboss.portal.server.plugins.windowstate.WindowState blah = org.jboss.portal.server.plugins.windowstate.WindowState.create(windowState.toString()); 52 if (!window.isSupportedWindowState(blah)) 53 { 54 throw new WindowStateException("Not supported", windowState); 55 } 56 windowURL.setWindowState(blah); 57 } 58 59 public void setPortletMode(PortletMode portletMode) throws PortletModeException 60 { 61 if (portletMode == null) 62 { 63 windowURL.setMode(null); 66 } 67 else 68 { 69 Mode mode = Mode.create(portletMode.toString()); 71 if (!window.isSupportedMode( 72 contentType, 73 mode)) 74 { 75 throw new PortletModeException("Not supported", portletMode); 76 } 77 78 windowURL.setMode(mode); 80 } 81 } 82 83 86 public void setParameter(String name, String value) 87 { 88 if (value == null) 90 { 91 throw new IllegalArgumentException ("value cannot be null"); 92 } 93 windowURL.setTargetParameter(name, value); 94 } 95 96 public void setParameter(String name, String [] values) 97 { 98 if (values == null) 100 { 101 throw new IllegalArgumentException ("value cannot be null"); 102 } 103 windowURL.setTargetParameter(name, values); 104 } 105 106 public void setParameters(Map parameters) 107 { 108 Parameters parameterMap = windowURL.getTargetParameters(); 110 parameterMap.setParameterMap(parameters); 111 } 112 113 public void setSecure(boolean secure) throws PortletSecurityException 114 { 115 windowURL.setSecure(Boolean.valueOf(secure)); 116 } 117 118 public String toString() 119 { 120 return resp.createURL(windowURL, true); 121 } 122 } 123 | Popular Tags |