1 7 package org.exoplatform.services.wsrp.producer.impl.helpers; 8 9 10 import java.util.Enumeration ; 11 import java.util.List ; 12 import org.exoplatform.commons.utils.IdentifierUtil; 13 import org.exoplatform.services.portletcontainer.helper.BasePortletURL; 14 import org.exoplatform.services.wsrp.WSRPConstants; 15 import org.exoplatform.services.wsrp.exceptions.WSRPException; 16 import org.exoplatform.services.wsrp.producer.PersistentStateManager; 17 18 22 public class ConsumerRewriterPortletURLImp extends BasePortletURL{ 23 24 private String sessionID; 25 private String portletHandle; 26 private String baseURL; 27 private PersistentStateManager stateManager; 28 29 public ConsumerRewriterPortletURLImp(String type, String markup, 30 List supports, 31 boolean isCurrentlySecured, 32 List customWindowStates, 33 Enumeration supportedWindowState, 34 String baseURL, String portletHandle, 35 PersistentStateManager stateManager, 36 String sessionID){ 37 super(type, markup, supports, isCurrentlySecured, 38 customWindowStates, supportedWindowState); 39 this.baseURL = baseURL; 40 this.portletHandle = portletHandle; 41 this.stateManager = stateManager; 42 this.sessionID = sessionID; 43 } 44 45 public String toString() { 46 if(!setSecureCalled && isCurrentlySecured){ 47 isSecure = true; 48 } 49 50 String navigationalState = IdentifierUtil.generateUUID(this); 51 try { 52 stateManager.putNavigationalState(navigationalState, parameters); 53 } catch (WSRPException e) { 54 e.printStackTrace(); 55 } 56 57 StringBuffer sB = new StringBuffer (); 58 sB.append(baseURL); 59 sB.append("&"); 60 sB.append(WSRPConstants.WSRP_URL_TYPE); 61 sB.append("="); 62 sB.append(type); 63 sB.append("&"); 64 sB.append(WSRPConstants.WSRP_PORTLET_HANDLE); 65 sB.append("="); 66 sB.append(portletHandle); 67 sB.append("&"); 68 sB.append(WSRPConstants.WSRP_NAVIGATIONAL_STATE); 69 sB.append("="); 70 sB.append(navigationalState); 71 sB.append("&"); 72 sB.append(WSRPConstants.WSRP_SESSION_ID); 73 sB.append("="); 74 sB.append(sessionID); 75 sB.append("&"); 76 sB.append(WSRPConstants.WSRP_SECURE_URL); 77 sB.append("="); 78 sB.append(isSecure); 79 80 if (requiredPortletMode != null) { 81 sB.append("&"); 82 sB.append(WSRPConstants.WSRP_MODE); 83 sB.append("="); 84 sB.append(requiredPortletMode); 85 } 86 if (requiredWindowState != null) { 87 sB.append("&"); 88 sB.append(WSRPConstants.WSRP_WINDOW_STATE); 89 sB.append("="); 90 sB.append(requiredWindowState); 91 } 92 sB.append(WSRPConstants.WSRP_REWITE_SUFFFIX); 93 return sB.toString(); 94 } 95 96 97 98 } 99 | Popular Tags |