private String getGeneratedUrlForLauncherModel(PortletRequest portletRequest) {
   assert (this.launchUrlPortletFname != null) : "launchUrlPortletFname cannot be null";
   assert (this.launchUrlType != null) : "launchUrlType cannot be null";
   final HttpServletRequest httpRequest =
       this.portalRequestUtils.getPortletHttpRequest(portletRequest);
   final IPortalUrlBuilder portalUrlBuilder =
       this.portalUrlProvider.getPortalUrlBuilderByPortletFName(
           httpRequest, this.launchUrlPortletFname, this.launchUrlType);
   return portalUrlBuilder.getUrlString();
 }
  protected String getUrlString(IRedirectionUrl url, HttpServletRequest request) {

    if (url instanceof ExternalRedirectionUrl) {
      ExternalRedirectionUrl externalUrl = (ExternalRedirectionUrl) url;
      StringBuffer urlStr = new StringBuffer();
      urlStr.append(externalUrl.getUrl());

      try {

        // add any additional parameters
        String separator = "?";
        for (Map.Entry<String, String[]> param : externalUrl.getAdditionalParameters().entrySet()) {
          for (String value : param.getValue()) {
            urlStr.append(separator);
            urlStr.append(param.getKey());
            urlStr.append("=");
            urlStr.append(URLEncoder.encode(value, "UTF-8"));
            separator = "&";
          }
        }

        // add any dynamic parameters
        for (Map.Entry<String, String> param : externalUrl.getDynamicParameters().entrySet()) {
          String[] values = request.getParameterValues(param.getKey());
          if (values != null) {
            for (String value : values) {
              urlStr.append(separator);
              urlStr.append(param.getValue());
              urlStr.append("=");
              urlStr.append(URLEncoder.encode(value, "UTF-8"));
              separator = "&";
            }
          }
        }
        return urlStr.toString();

      } catch (UnsupportedEncodingException ex) {
        log.error("Unable to encode URL parameter for external service redirect", ex);
        return null;
      }

    } else {

      PortletRedirectionUrl portletUrl = (PortletRedirectionUrl) url;

      // create the base URL for the portlet
      final IPortletWindow portletWindow =
          this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(
              request, portletUrl.getFname());
      final IPortalUrlBuilder portalUrlBuilder =
          this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(
              request, portletWindow.getPortletWindowId(), portletUrl.getType());
      final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getTargetedPortletUrlBuilder();
      portletUrlBuilder.setPortletMode(portletUrl.getMode());
      portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);

      // for each of the defined additional parameters, add a matching
      // parameter to the portlet URL
      for (Map.Entry<String, String[]> param : portletUrl.getAdditionalParameters().entrySet()) {
        portletUrlBuilder.addParameter(param.getKey(), param.getValue());
      }

      // for each of the defined dynamic parameters, add a parameter if
      // the value submitted to this service was non-null
      for (Map.Entry<String, String> param : portletUrl.getDynamicParameters().entrySet()) {
        String[] values = request.getParameterValues(param.getKey());
        if (values != null) {
          portletUrlBuilder.addParameter(param.getValue(), values);
        }
      }

      return portalUrlBuilder.getUrlString();
    }
  }