Cocoon
  1. Cocoon
  2. COCOON-2319

Bad Environment context when redirecting to cocoon:// with a sitemap not located in the webapp context

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.11
    • Fix Version/s: 2.1.12
    • Component/s: * Cocoon Core
    • Labels:
      None
    • Other Info:
      Patch available

      Description

      Let say I have a root sitemap not located in the webapp context, with a simple pipeline like :

      {code:xml}
      <map:match pattern="foo">
        <map:read src="foo.png"/>
      </map:match>
      {code}

      If I call directly, the URI /foo, I correctly get the image foo.png


      Now, if I have a second sitemap elsewhere, mounted from the first one, with another simple pipeline like :

      {code:xml}
      <map:match pattern="bar">
        <map:redirect-to uri="cocoon://foo"/>
      </map:match>
      {code}

      If I call /foo/bar, I get a 404 Not Found saying that it looks for foo.png in the webapp context, and not relative to the root sitemap.

      Looking at the code, I discovered that in the first case, in the method TreeProcessor.setupConcreteProcessor(), we have a statement especially for handling the case of sitemap not located in the webapp context :
      {code:java}
              if (this.parent == null) {
                  // Ensure root sitemap uses the correct context, even if not located in the webapp context
                  env.changeContext("", this.source.getURI());
              }
      {code}

      while in the second case, where the ConcreteTreeProcessor is managed in the method ConcreteTreeProcessor.handleCocoonRedirect(), there's no such statement.

      I'll provide a patch for fixing this, but looking deeper at the code, I found that this looked like a hack (even for the existing statement).
      I think it would be better to have the right root context at the creation of the environment, and not to have to change it later when building the ConcreteTreeProcessor.

        Activity

        Cédric Damioli created issue -
        Cédric Damioli made changes -
        Field Original Value New Value
        Attachment ConcreteTreeProcessor.java.patch [ 12506986 ]
        Cédric Damioli made changes -
        Other Info Patch available [ 10054 ]
        Hide
        Cédric Damioli added a comment -
        Committed in revision 1303732
        Show
        Cédric Damioli added a comment - Committed in revision 1303732
        Cédric Damioli made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Cédric Damioli [ cedric ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Cédric Damioli
            Reporter:
            Cédric Damioli
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development