1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.pluto.driver.core;
18
19 import javax.portlet.PortletMode;
20 import javax.portlet.WindowState;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.apache.pluto.container.PortletContainer;
25 import org.apache.pluto.container.PortletContainerException;
26 import org.apache.pluto.container.PortletWindow;
27 import org.apache.pluto.container.PortletWindowID;
28 import org.apache.pluto.container.driver.PlutoServices;
29 import org.apache.pluto.container.om.portlet.PortletDefinition;
30 import org.apache.pluto.driver.core.PortletWindowIDImpl;
31 import org.apache.pluto.driver.services.portal.PortletWindowConfig;
32 import org.apache.pluto.driver.url.PortalURL;
33
34
35
36
37 public class PortletWindowImpl implements PortletWindow {
38
39
40 private static final Logger LOG = LoggerFactory.getLogger(PortletWindowImpl.class);
41
42
43
44 private PortletWindowConfig config;
45 private PortalURL portalURL;
46 private PortletWindowIDImpl objectIdImpl;
47 private PortletDefinition portlet;
48 private int _nLutecePortletId;
49
50
51
52
53
54
55
56
57 public PortletWindowImpl(PortletContainer container, PortletWindowConfig config, PortalURL portalURL, int nLutecePortletId) {
58 this.config = config;
59 this.portalURL = portalURL;
60 this._nLutecePortletId = nLutecePortletId;
61 try
62 {
63 String applicationName = config.getContextPath();
64 if (applicationName.length() >0 )
65 {
66 applicationName = applicationName.substring(1);
67 }
68 this.portlet = PlutoServices.getServices().getPortletRegistryService().getPortlet(applicationName, config.getPortletName());
69 }
70 catch (PortletContainerException ex)
71 {
72 String message = "Unable to load Portlet App Deployment Descriptor:"+ ex.getMessage();
73 ex.printStackTrace();
74 LOG.error(message, ex);
75 throw new RuntimeException(message);
76 }
77 }
78
79 public PortletWindowImpl(PortletContainer container, PortletWindowConfig config, PortalURL portalURL) {
80 this.config = config;
81 this.portalURL = portalURL;
82 try
83 {
84 String applicationName = config.getContextPath();
85 if (applicationName.length() >0 )
86 {
87 applicationName = applicationName.substring(1);
88 }
89 this.portlet = PlutoServices.getServices().getPortletRegistryService().getPortlet(applicationName, config.getPortletName());
90 }
91 catch (PortletContainerException ex)
92 {
93 String message = "Unable to load Portlet App Deployment Descriptor:"+ ex.getMessage();
94 ex.printStackTrace();
95 LOG.error(message, ex);
96 throw new RuntimeException(message);
97 }
98 }
99
100
101
102
103 public String getContextPath() {
104 return config.getContextPath();
105 }
106
107 public String getPortletName() {
108 return config.getPortletName();
109 }
110
111 public WindowState getWindowState() {
112 return portalURL.getWindowState(getId().getStringId());
113 }
114 public void setWindowState(String strWindowState) {
115 if(strWindowState != null)
116 {
117 WindowState windowState = new WindowState(strWindowState);
118 portalURL.setWindowState(getId().getStringId(), windowState);
119 }
120 }
121
122 public PortletMode getPortletMode() {
123 return portalURL.getPortletMode(getId().getStringId());
124 }
125
126 public void setPortletMode(String strPortletMode) {
127 if(strPortletMode != null)
128 {
129 PortletMode portletMode = new PortletMode(strPortletMode);
130 portalURL.setPortletMode(getId().getStringId(), portletMode );
131 }
132 }
133
134 public PortletWindowID getId() {
135 if (objectIdImpl == null) {
136 objectIdImpl = PortletWindowIDImpl.createFromString(config.getId());
137 }
138 return objectIdImpl;
139 }
140
141 public PortletDefinition getPortletDefinition() {
142 return portlet;
143 }
144
145 public int getLutecePortletID()
146 {
147 return _nLutecePortletId;
148 }
149 }