* @param resourceId - can be empty string
* @return IPortletUrlBuilder
* @since uPortal 4.1
*/
public IPortletUrlBuilder getPortletUrlBuilder(HttpServletRequest request, IPortalUrlBuilder portalUrlBuilder, String fname, String layoutId, String state, String mode, String copyCurrentRenderParameters, String resourceId) {
final IPortletUrlBuilder portletUrlBuilder;
if (StringUtils.isNotEmpty(fname)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, fname);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
}
else if (StringUtils.isNotEmpty(layoutId)) {
final IPortletWindow portletWindow = this.portletWindowRegistry.getOrCreateDefaultPortletWindowByLayoutNodeId(request, layoutId);
final IPortletWindowId portletWindowId = portletWindow.getPortletWindowId();
portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
}
else {
final IPortletWindowId targetPortletWindowId = portalUrlBuilder.getTargetPortletWindowId();
if (targetPortletWindowId == null) {
if (this.logger.isDebugEnabled()) {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet.", new Throwable());
}
else {
this.logger.warn("Can only target the default portlet if the root portal-url targets a portlet. Enable debug for stack trace.");
}
return new FailSafePortletUrlBuilder(null, portalUrlBuilder);
}
portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
}
portletUrlBuilder.setCopyCurrentRenderParameters(Boolean.parseBoolean(copyCurrentRenderParameters));
if (StringUtils.isNotEmpty(state)) {
portletUrlBuilder.setWindowState(PortletUtils.getWindowState(state));
}
if (StringUtils.isNotEmpty(mode)) {
portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(mode));
}
if(StringUtils.isNotEmpty(resourceId) && portletUrlBuilder.getPortalUrlBuilder().getUrlType()==UrlType.RESOURCE){
portletUrlBuilder.setResourceId(resourceId);
}
return portletUrlBuilder;
}