1 7 package org.exoplatform.services.wsrp.producer.impl.helpers; 8 9 import java.util.Enumeration ; 10 import java.util.List ; 11 import org.apache.commons.lang.StringUtils; 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 ProducerRewriterPortletURLImp extends BasePortletURL{ 23 24 private String sessionID; 25 private String portletHandle; 26 private String template; 27 private PersistentStateManager stateManager; 28 29 public ProducerRewriterPortletURLImp(String type, String markup, 30 List supports, 31 boolean isCurrentlySecured, 32 List customWindowStates, 33 Enumeration supportedWindowState, 34 String template, String portletHandle, 35 PersistentStateManager stateManager, 36 String sessionID){ 37 super(type, markup, supports, isCurrentlySecured, 38 customWindowStates, supportedWindowState); 39 this.template = template; 40 this.portletHandle = portletHandle; 41 this.stateManager = stateManager; 42 this.sessionID = sessionID; 43 } 44 45 public String toString() { 46 String secureInfo ="false"; 47 if(!setSecureCalled && isCurrentlySecured){ 48 isSecure = true; 49 secureInfo = "true"; 50 } 51 String navigationalState = IdentifierUtil.generateUUID(this); 52 String temp = template; 53 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_URL_TYPE + "}", type); 54 if(requiredPortletMode != null) { 55 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_MODE + "}", requiredPortletMode.toString()); 56 } else { 57 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_MODE + "}", ""); 58 } 59 if(requiredWindowState != null){ 60 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_WINDOW_STATE + "}", requiredWindowState.toString()); 61 } else { 62 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_WINDOW_STATE + "}", ""); 63 } 64 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_SECURE_URL + "}", secureInfo); 65 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_PORTLET_HANDLE + "}", portletHandle); 66 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_NAVIGATIONAL_STATE + "}", navigationalState); 67 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_SESSION_ID + "}", sessionID); 68 69 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_PORTLET_INSTANCE_KEY + "}", ""); 70 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_USER_CONTEXT_KEY + "}", ""); 71 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_URL + "}", ""); 72 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_REQUIRES_REWRITE + "}", ""); 73 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_INTERACTION_STATE + "}", ""); 74 temp = StringUtils.replace(temp, "{" + WSRPConstants.WSRP_FRAGMENT_ID + "}", type); 75 76 try { 77 stateManager.putNavigationalState(navigationalState, parameters); 78 } catch (WSRPException e) { 79 e.printStackTrace(); 80 } 81 return temp; 82 } 83 84 } 85 | Popular Tags |