errorMsg = getErrorMsg();
}
}
PortalEnvironment env = (PortalEnvironment) request.getAttribute(PortalEnvironment.REQUEST_PORTALENV);
PortalURL thisURL = env.getRequestedPortalURL();
PortalControlParameter thisControl = new PortalControlParameter(thisURL);
if (thisControl.isOnePortletWindowMaximized()) {
WindowState currentState = thisControl.getState(portletWindow);
if (!WindowState.MAXIMIZED.equals(currentState)) {
return;
}
}
PortletDefinition portletDefinition = portletWindow.getPortletEntity().getPortletDefinition();
LanguageSet languageSet = portletDefinition.getLanguageSet();
Language lang = languageSet.get(request.getLocale());
String title = lang != null ? lang.getTitle() : "no title available";
// create a PortletInfo object. This is used to communicate with
// the header and footer JSP pages for this portlet
PortletInfo portletInfo = new PortletInfo();
ServletDefinition servletDefinition = portletWindow.getPortletEntity().getPortletDefinition().getServletDefinition();
if (servletDefinition != null && !servletDefinition.isUnavailable()) {
PrintWriter writer2 = new PrintWriter(storedWriter);
// create a wrapped response which the Portlet will be rendered to
wrappedResponse = (ServletResponseImpl)ServletObjectAccess.getStoredServletResponse(response, writer2);
try {
// render the Portlet to the wrapped response, to be output later.
PortletContainerFactory.getPortletContainer().renderPortlet(portletWindow, wrappedRequest, wrappedResponse);
} catch (UnavailableException e) {
log.error("Portlet is Unavailable", e);
writer2.println("the portlet is currently unavailable!");
ServletDefinitionCtrl servletDefinitionCtrl = (ServletDefinitionCtrl) ControllerObjectAccess.get(portletWindow.getPortletEntity().getPortletDefinition().getServletDefinition());
if (e.isPermanent()) {
servletDefinitionCtrl.setAvailable(Long.MAX_VALUE);
} else {
int unavailableSeconds = e.getUnavailableSeconds();
if (unavailableSeconds <= 0) {
unavailableSeconds = 60; // arbitrary default
}
servletDefinitionCtrl.setAvailable(System.currentTimeMillis() + unavailableSeconds * 1000);
}
} catch (Exception e) {
log.error("Error in Portlet", e);
writer2.println(getErrorMsg());
}
String dyn_title = ((DynamicTitleServiceImpl) FactoryAccess.getDynamicTitleContainerService()).getDynamicTitle(portletWindow, request);
if (dyn_title != null) {
title = dyn_title;
}
}
// set the title, so the header JSP page can use it when rendering
portletInfo.setTitle(title);
DynamicInformationProvider provider = FactoryAccess.getDynamicProvider(request);
ContentType supported = portletDefinition.getContentTypeSet().get(wrappedResponse.getContentType());
PortalContextProvider portalContextProvider = FactoryAccess.getStaticProvider().getPortalContextProvider();
// get the list of modes this Portlet supports
if (supported != null && portalContextProvider != null) {
// if portlet supports portlet modes
Iterator modes = supported.getPortletModes();
while (modes.hasNext()) {
PortletMode mode = (PortletMode) modes.next();
// check whether portal also supports portlet mode
boolean portalSupport = false;
Iterator portalSupportedModes = portalContextProvider.getSupportedPortletModes().iterator();
while (portalSupportedModes.hasNext()) {
PortletMode portalSupportedMode = (PortletMode) portalSupportedModes.next();
if (mode.equals(portalSupportedMode)) {
portalSupport = true;
break;
}
}
// create links for portlet modes in portlet header
if (portalSupport) {
env = (PortalEnvironment) request.getAttribute(PortalEnvironment.REQUEST_PORTALENV);
PortalURL modeURL = env.getRequestedPortalURL();
PortalControlParameter control = new PortalControlParameter(modeURL);
PortletMode currentMode = control.getMode(portletWindow);
control.setMode(portletWindow, mode);
portletInfo.addPortletMode(mode, modeURL.toString(control, new Boolean(request.isSecure())), mode.equals(currentMode));
}
}
// get the list of window states this Portlet supports
Iterator states = portalContextProvider.getSupportedWindowStates().iterator();
while (states.hasNext()) {
WindowState state = (WindowState) states.next();
env = (PortalEnvironment) request.getAttribute(PortalEnvironment.REQUEST_PORTALENV);
PortalURL stateURL = env.getRequestedPortalURL();
PortalControlParameter control = new PortalControlParameter(stateURL);
WindowState currentState = control.getState(portletWindow);
control.setState(portletWindow, state);
portletInfo.addPortletWindowState(state.toString().substring(0, 3), stateURL.toString(control, new Boolean(request.isSecure())), state.equals(currentState));