1 16 19 20 package org.apache.pluto.portalImpl.core; 21 22 import java.util.Iterator ; 23 import java.util.Map ; 24 25 import javax.portlet.PortletMode; 26 import javax.portlet.WindowState; 27 28 import org.apache.pluto.om.window.PortletWindow; 29 import org.apache.pluto.services.information.PortletURLProvider; 30 31 public class PortletURLProviderImpl implements PortletURLProvider { 32 33 private DynamicInformationProviderImpl provider; 34 private PortletWindow portletWindow; 35 private PortletMode mode; 36 private WindowState state; 37 private boolean action; 38 private boolean secure; 39 private boolean clearParameters; 40 private Map parameters; 41 42 public PortletURLProviderImpl(DynamicInformationProviderImpl provider, 43 PortletWindow portletWindow) 44 { 45 this.provider = provider; 46 this.portletWindow = portletWindow; 47 } 48 49 51 public void setPortletMode(PortletMode mode) 52 { 53 this.mode = mode; 54 } 55 56 public void setWindowState(WindowState state) 57 { 58 this.state = state; 59 } 60 61 public void setAction() 62 { 63 action = true; 64 } 65 66 public void setSecure() 67 { 68 secure = true; 69 } 70 71 public void clearParameters() 72 { 73 clearParameters = true; 74 } 75 76 public void setParameters(Map parameters) 77 { 78 this.parameters = parameters; 79 } 80 81 public String toString() 82 { 83 PortalURL url = PortalEnvironment.getPortalEnvironment(provider.request).getRequestedPortalURL(); 84 85 PortalControlParameter controlURL = new PortalControlParameter(url); 86 87 if (mode != null) { 88 controlURL.setMode(portletWindow, mode); 89 } 90 91 if (state != null) { 92 controlURL.setState(portletWindow, state); 93 } 94 95 if (clearParameters) { 96 controlURL.clearRenderParameters(portletWindow); 97 } 98 99 controlURL.setPortletId(portletWindow); 101 if (action) { 102 controlURL.setAction(portletWindow); 103 } 104 105 106 if (parameters != null) { 107 Iterator names = parameters.keySet().iterator(); 108 while (names.hasNext()) { 109 String name = (String )names.next(); 110 Object value = parameters.get(name); 111 String [] values = value instanceof String ? new String [] {(String )value} : (String [])value; 112 if (action) { 113 controlURL.setRequestParam(name,values); 115 } else { 116 controlURL.setRenderParam(portletWindow, name, values ); 117 } 118 } 119 } 120 121 return url.toString(controlURL,new Boolean (secure)); 122 } 123 124 } 125 | Popular Tags |