Validate.notNull(portletWindowId, "IPortletWindowId was null");
final StringBuilder url = this.getUrlBase(request);
final IPortletWindow portletWindow = this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
final IPortletEntity portletEntity = this.portletEntityRegistry.getPortletEntity(portletWindow.getPortletEntityId());
//Add folder information if available: /tabId
final String channelSubscribeId = portletEntity.getChannelSubscribeId();
// if not a transient node, we need to lookup user layout information
if (!channelSubscribeId.startsWith(TransientUserLayoutManagerWrapper.SUBSCRIBE_PREFIX)) {
final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);
final IUserPreferencesManager preferencesManager = userInstance.getPreferencesManager();
final IUserLayoutManager userLayoutManager = preferencesManager.getUserLayoutManager();
final IUserLayout userLayout = userLayoutManager.getUserLayout();
final XPathExpression findChannelTabExpression = this.getFindChannelTabIdExpression(channelSubscribeId);
final String tabId = userLayout.findNodeId(findChannelTabExpression);
//Add folder ID of parent tab if it exists
if (tabId != null) {
final String folderId = this.verifyFolderId(request, tabId);
url.append(folderId);
url.append("/");
}
}
//Add state information
final WindowState requestedWindowState = portalPortletUrl.getWindowState();
final WindowState currentWindowState = portletWindow.getWindowState();
final WindowState urlWindowState = requestedWindowState != null ? requestedWindowState : currentWindowState;
String windowStateString = UrlState.NORMAL.toString().toLowerCase();
if (WindowState.MAXIMIZED.equals(urlWindowState)) {
windowStateString = UrlState.MAX.toString().toLowerCase();
}
else if (IPortletAdaptor.DETACHED.equals(urlWindowState)) {
windowStateString = UrlState.DETACHED.toString().toLowerCase();
}
else if (IPortletAdaptor.EXCLUSIVE.equals(urlWindowState)) {
windowStateString = UrlState.EXCLUSIVE.toString().toLowerCase();
}
else {
this.logger.warn("Unknown WindowState '" + urlWindowState + "' specified for portlet window " + portletWindow + ", defaulting to NORMAL");
}
url.append(windowStateString);
//Add channel information: /fname.chanid
final IPortletDefinition portletDefinition = this.portletDefinitionRegistry.getPortletDefinition(portletEntity.getPortletDefinitionId());
final IChannelDefinition channelDefinition = portletDefinition.getChannelDefinition();
final String fname = channelDefinition.getFName();
final String validFname = FunctionalNameType.INVALID_CHARS_PATTERN.matcher(fname).replaceAll("_");
url.append("/").append(validFname).append(".").append(channelSubscribeId);