Search code examples
includeloopbackapache-cocoon

Cocoon cinclude from another pipeline


I've got a Cocoon setup with a pipeline whose transformer contains something like this:

<cinclude:include src="https://my-app/get-some-data" />

Now, the URL included there is actually coming from Cocoon, and I have a TLS certificate that Java doesn't trust, so I get errors about PKI certification paths. I can "easily" solve that (and have been for some time, now) by specifying a truststore for the JVM process that contains my server's TLS certificate in it.

I'd like to stop doing that for at least two reasons:

  1. When my server certificate needs an update, I have to update my trust store and bounce Cocoon
  2. It could be more efficient (no loopback HTTP request, no TLS handshake, etc.)

Does cinclude understand Cocoon-relative paths?

I'm looking for something like this:

<cinclude:include src="cocoon://get-some-data" />

Does something like that exist?


Solution

  • Yes, you can do exactly this. The desired syntax is already in the question, with a slight modification. For example, let's say we have this match configured within a sitemap:

    <map:match pattern="get-some-data">
       ...
    </map:match>
    
    <map:match pattern="primary-request">
      ...
      <map:transform type="cinclude" />
      ..
    </map:match>
    

    Using <cinclude> within the "primary-request" pipeline to include from the other pipeline simply requires this:

    <cinclude:include src="cocoon:/get-some-data?parameters" />
    

    This specific will only work for pipelines within the same sitemap. If you need to reference pipelines in other sitemaps, it requires a bit more setup -- but that's outside the scope of the question, here.