1 5 package org.exoplatform.services.portletcontainer.impl.portletAPIImp; 6 7 8 import java.net.URLEncoder ; 9 import java.util.Enumeration ; 10 import java.util.Iterator ; 11 import java.util.List ; 12 import java.util.Set ; 13 import org.exoplatform.Constants; 14 import org.exoplatform.services.portletcontainer.helper.BasePortletURL; 15 import org.exoplatform.services.portletcontainer.pci.WindowID; 16 23 public class PortletURLImp extends BasePortletURL { 24 25 private WindowID windowID; 26 27 private String baseURL; 28 29 public PortletURLImp(String type, String markup, 30 List supports, 31 boolean isCurrentlySecured, 32 List customWindowStates, 33 Enumeration supportedWindowState, 34 String baseURL, WindowID windowID){ 35 super(type, markup, supports, isCurrentlySecured, 36 customWindowStates, supportedWindowState); 37 this.baseURL = baseURL; 38 this.windowID = windowID; 39 } 40 41 public String toString() { 42 if(!setSecureCalled && isCurrentlySecured) 43 isSecure = true; 44 45 StringBuffer sB = new StringBuffer (); 46 sB.append(baseURL); 47 sB.append(Constants.AMPERSAND); 52 sB.append(Constants.TYPE_PARAMETER); 53 sB.append("="); 54 sB.append(type); 55 sB.append(Constants.AMPERSAND); 56 sB.append(Constants.SECURE_PARAMETER); 57 sB.append("="); 58 sB.append(isSecure); 59 60 if (requiredPortletMode != null) { 61 sB.append(Constants.AMPERSAND); 62 sB.append(Constants.PORTLET_MODE_PARAMETER); 63 sB.append("="); 64 sB.append(requiredPortletMode); 65 } 66 if (requiredWindowState != null) { 67 sB.append(Constants.AMPERSAND); 68 sB.append(Constants.WINDOW_STATE_PARAMETER); 69 sB.append("="); 70 sB.append(requiredWindowState); 71 } 72 73 Set names = parameters.keySet(); 74 for (Iterator iterator = names.iterator(); iterator.hasNext();) { 75 String name = (String ) iterator.next() ; 76 Object obj = parameters.get(name) ; 77 if (obj instanceof String ) { 78 String value = (String ) obj ; 79 sB.append(Constants.AMPERSAND); 80 sB.append(URLEncoder.encode(name)); 81 sB.append("="); 82 sB.append(URLEncoder.encode(value)); 83 } else { 84 String [] values = (String []) obj ; 85 for (int i=0; i < values.length ; i++) { 86 sB.append(Constants.AMPERSAND); 87 sB.append(URLEncoder.encode(name)); 88 sB.append("="); 89 sB.append(URLEncoder.encode(values[i])); 90 } 91 } 92 } 93 return sB.toString(); 94 } 95 96 } 97 | Popular Tags |