KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > wsrp > producer > impl > helpers > ConsumerRewriterPortletURLImp


1 /*
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  *
5  * Created on 12 janv. 2004
6  */

7 package org.exoplatform.services.wsrp.producer.impl.helpers;
8
9
10 import java.util.Enumeration JavaDoc;
11 import java.util.List JavaDoc;
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 /**
19  * @author Mestrallet Benjamin
20  * benjmestrallet@users.sourceforge.net
21  */

22 public class ConsumerRewriterPortletURLImp extends BasePortletURL{
23
24   private String JavaDoc sessionID;
25   private String JavaDoc portletHandle;
26   private String JavaDoc baseURL;
27   private PersistentStateManager stateManager;
28
29   public ConsumerRewriterPortletURLImp(String JavaDoc type, String JavaDoc markup,
30                       List JavaDoc supports,
31                       boolean isCurrentlySecured,
32                       List JavaDoc customWindowStates,
33                       Enumeration JavaDoc supportedWindowState,
34                       String JavaDoc baseURL, String JavaDoc portletHandle,
35                       PersistentStateManager stateManager,
36                       String JavaDoc 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 JavaDoc toString() {
46     if(!setSecureCalled && isCurrentlySecured){
47       isSecure = true;
48     }
49
50     String JavaDoc navigationalState = IdentifierUtil.generateUUID(this);
51     try {
52       stateManager.putNavigationalState(navigationalState, parameters);
53     } catch (WSRPException e) {
54       e.printStackTrace();
55     }
56
57     StringBuffer JavaDoc sB = new StringBuffer JavaDoc();
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