Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-26665

User Group Site Pages: "VirtualLayout.injectVirtualGroupURL" is called, even when the Layout is of type URL

    Details

    • Branch Version/s:
      6.1.x
    • Backported to Branch:
      Committed
    • Liferay Contributor's Agreement:
      Accept

      Description

      In LR 6.1 VirtualLayout.injectVirtualGroupURL is called, even when the Layout is of type URL.

      The code snippet within injectVirtualGroupURL

      int pos = layoutURL.indexOf(group.getFriendlyURL());

      will return -1.

      Therefore the next statement

      sb.append(layoutURL.substring(0, pos));

      will fail.

      The bug can be reproduced as follows:

      • Create a User Group
      • Create a Page (private or public) of type URL within this User Group
      • Set a valid value for the URL field (e.g. http://www.liferay.com)
      • Assign a User to this User Group
      • Log in as this user and open user's (private or public) pages

      Error Message:

      javax.servlet.jsp.JspException: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getURL' in class com.liferay.portal.theme.NavItem threw exception java.lang.IllegalStateException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at test-theme_SERVLET_CONTEXT_/templates/navigation.vm[line 13, column 52]

      Possible solution:

      Check type of the Layout.

      public String getRegularURL(HttpServletRequest request)
      throws PortalException, SystemException {

      String layoutURL = _sourceLayout.getRegularURL(request);
      // Custom Code
      if(LayoutConstants.TYPE_URL.equals(_sourceLayout.getType()))

      { return layoutURL; }

      // Custom Code

      return injectVirtualGroupURL(layoutURL);
      }

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 12 weeks, 1 day ago

                  Subcomponents