protected void initPortletWindow(String uid) throws PortalException {
ChannelState channelState = (ChannelState)channelStateMap.get(uid);
ChannelRuntimeData rd = channelState.getRuntimeData();
ChannelStaticData sd = channelState.getStaticData();
ChannelData cd = channelState.getChannelData();
PortalControlStructures pcs = channelState.getPortalControlStructures();
try {
synchronized(this) {
if (!portletContainerInitialized) {
initPortletContainer(uid);
}
}
PortletContainerServices.prepare(uniqueContainerName);
// Get the portlet definition Id which must be specified as a publish
// parameter. The syntax of the ID is [portlet-context-name].[portlet-name]
String portletDefinitionId = sd.getParameter(portletDefinitionIdParamName);
if (portletDefinitionId == null) {
throw new PortalException("Missing publish parameter '" + portletDefinitionIdParamName + "'");
}
// Create the PortletDefinition
PortletDefinitionImpl portletDefinition = (PortletDefinitionImpl)InformationProviderAccess.getStaticProvider().getPortletDefinition(ObjectIDImpl.createFromString(portletDefinitionId));
if (portletDefinition == null) {
throw new PortalException("Unable to find portlet definition for ID '" + portletDefinitionId + "'");
}
ChannelDefinition channelDefinition = ChannelRegistryStoreFactory.getChannelRegistryStoreImpl().getChannelDefinition(Integer.parseInt(sd.getChannelPublishId()));
portletDefinition.setChannelDefinition(channelDefinition);
portletDefinition.loadPreferences();
// Create the PortletApplicationEntity
final PortletApplicationEntityImpl portAppEnt = new PortletApplicationEntityImpl();
portAppEnt.setId(portletDefinition.getId().toString());
portAppEnt.setPortletApplicationDefinition(portletDefinition.getPortletApplicationDefinition());
// Create the PortletEntity
PortletEntityImpl portletEntity = new PortletEntityImpl();
portletEntity.setId(sd.getChannelPublishId());
portletEntity.setPortletDefinition(portletDefinition);
portletEntity.setPortletApplicationEntity(portAppEnt);
portletEntity.setUserLayout(pcs.getUserPreferencesManager().getUserLayoutManager().getUserLayout());
portletEntity.setChannelDescription((IUserLayoutChannelDescription)pcs.getUserPreferencesManager().getUserLayoutManager().getNode(sd.getChannelSubscribeId()));
portletEntity.setPerson(sd.getPerson());
portletEntity.loadPreferences();
// Add the user information into the request See PLT.17.2.
Map userInfo = cd.getUserInfo();
if (userInfo == null) {
UserAttributeListImpl userAttributeList = ((PortletApplicationDefinitionImpl)portletDefinition.getPortletApplicationDefinition()).getUserAttributes();
// here we ask an overridable method to get the user attributes.
// you can extend CPortletAdapter to change the implementation of
// how we get user attributes. This whole initPortletWindow method
// is also overridable.
//
// Note that we will only call getUserInfo() once.
userInfo = getUserInfo(uid, sd, userAttributeList);
if (log.isTraceEnabled()) {
log.trace("For user [" + uid + "] got user info : [" + userInfo + "]");
}
cd.setUserInfo(userInfo);
}
// Wrap the request
ServletRequestImpl wrappedRequest = new ServletRequestImpl(pcs.getHttpServletRequest(), sd.getPerson(), portletDefinition.getInitSecurityRoleRefSet());
// Now create the PortletWindow and hold a reference to it
PortletWindowImpl portletWindow = new PortletWindowImpl();
portletWindow.setId(sd.getChannelSubscribeId());
portletWindow.setPortletEntity(portletEntity);
portletWindow.setChannelRuntimeData(rd);
portletWindow.setHttpServletRequest(wrappedRequest);
cd.setPortletWindow(portletWindow);
// Ask the container to load the portlet
synchronized(this) {
portletContainer.portletLoad(portletWindow, wrappedRequest, pcs.getHttpServletResponse());
}
cd.setPortletWindowInitialized(true);
} catch (Exception e) {