KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Enumeration JavaDoc;
10 import java.util.List JavaDoc;
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 /**
19  * @author Mestrallet Benjamin
20  * benjmestrallet@users.sourceforge.net
21  */

22 public class ProducerRewriterPortletURLImp extends BasePortletURL{
23
24   private String JavaDoc sessionID;
25   private String JavaDoc portletHandle;
26   private String JavaDoc template;
27   private PersistentStateManager stateManager;
28
29   public ProducerRewriterPortletURLImp(String JavaDoc type, String JavaDoc markup,
30                       List JavaDoc supports,
31                       boolean isCurrentlySecured,
32                       List JavaDoc customWindowStates,
33                       Enumeration JavaDoc supportedWindowState,
34                       String JavaDoc template, String JavaDoc portletHandle,
35                       PersistentStateManager stateManager,
36                       String JavaDoc 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 JavaDoc toString() {
46     String JavaDoc secureInfo ="false";
47     if(!setSecureCalled && isCurrentlySecured){
48       isSecure = true;
49       secureInfo = "true";
50     }
51     String JavaDoc navigationalState = IdentifierUtil.generateUUID(this);
52     String JavaDoc 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