Jetspeed 2
  1. Jetspeed 2
  2. JS2-1238

Pipeline mapper needed to find mapping path by a pipeline name

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.2.2
    • Component/s: Components Core
    • Labels:
      None

      Description

      Currently we have a configuration for the default pipeline in jetspeed.properties as follows:

      pipeline.default = jetspeed-pipeline

      Also, the default pipeline name is used in JetspeedEngine to find a default pipeline component when there's no servlet path mapping is found.
      Obviously, this is a good feature because we don't have to stick to physical servlet paths.

      I think this should be extended as a separate component like PipelineMapper to allow some custom servlet filters to leverage it.
      For example, when a custom servlet filter is responsible for choosing a pipeline for the request and forwarding the request, then the servlet filter should be able to find the servlet path mapped to a pipeline because the servlet filter needs to use ServletContext.getRequestDispatcher(contextRelativePath).forward().

      Therefore, I think we can add PipelineMapper component like this:

      interface PipelineMapper

      { /** Finds pipeline which bean id is equals to pipelineId. */ Pipeline getPipelineById(String pipelineId); // ex) getPipelineById("jetspeed-pipeline"); /** Finds pipeline which name is equals to pipelineName. */ Pipeline getPipelineByName(String pipelineName); // ex) getPipelineByName("JetspeedPipeline") /** Find the servlet mapping path by pipeline bean id. */ String getPathByPipelineId(String pipelineId); // ex) getPathByPipelineId("jetspeed-pipeline"); /** Find the servlet mapping path by pipeline name. */ String getPathByPipelineName(String pipelineId); // ex) getPathByPipelineName("JetspeedPipeline"); }

      FYI, personally, I think it's better to use pipeline name consistently, but it is necessary to keep operations with pipeline bean IDs for backward compatibility.

      This could modify pipelines.xml slightly by wrapping the existing 'pipeline-map' bean, and add one pair of interface/default impl.

      If there's any objection, please let me know.

      Regards,

      Woonsan

        Activity

        Hide
        Woonsan Ko added a comment -

        In configurations we already use pipeline bean IDs instead of their names. So, I'll keep those as it is.
        I've committed my patch, the interface looks like this:

        • Pipeline getPipelineByMappedPath(String mappedPath);
        • Pipeline getPipelineById(String id);
        • String getMappedPathByPipelineId(String pipelineId);
        • String [] getMappedPathsByPipelineId(String pipelineId);

        So, for example, if a site has a custom filter which is responsible for forwarding to one of portal pipelines, it can now use PipelineMapper to find physical servlet mapping paths instead of hard-coded paths.
        Here's an example code:

        import org.apache.jetspeed.engine.JetspeedEngineConstants;
        import org.apache.jetspeed.pipeline.PipelineMapper;

        PipelineMapper mapper = (PipelineMapper) Jetspeed.getComponentManager().getComponent("pipeline-mapper");
        String defaultPipelineId = Jetspeed.getConfiguration().getString(JetspeedEngineConstants.PIPELINE_DEFAULT);
        //defaultPipelineId = "jetui-pipeline";
        String pipelinePath = mapper.getMappedPathByPipelineId(defaultPipelineId);
        servletContext.getRequestDispatcher(pipelinePath + "/default-page.psml").forward(req, res);

        Regards,

        Woonsan

        Show
        Woonsan Ko added a comment - In configurations we already use pipeline bean IDs instead of their names. So, I'll keep those as it is. I've committed my patch, the interface looks like this: Pipeline getPipelineByMappedPath(String mappedPath); Pipeline getPipelineById(String id); String getMappedPathByPipelineId(String pipelineId); String [] getMappedPathsByPipelineId(String pipelineId); So, for example, if a site has a custom filter which is responsible for forwarding to one of portal pipelines, it can now use PipelineMapper to find physical servlet mapping paths instead of hard-coded paths. Here's an example code: import org.apache.jetspeed.engine.JetspeedEngineConstants; import org.apache.jetspeed.pipeline.PipelineMapper; PipelineMapper mapper = (PipelineMapper) Jetspeed.getComponentManager().getComponent("pipeline-mapper"); String defaultPipelineId = Jetspeed.getConfiguration().getString(JetspeedEngineConstants.PIPELINE_DEFAULT); //defaultPipelineId = "jetui-pipeline"; String pipelinePath = mapper.getMappedPathByPipelineId(defaultPipelineId); servletContext.getRequestDispatcher(pipelinePath + "/default-page.psml").forward(req, res); Regards, Woonsan

          People

          • Assignee:
            Woonsan Ko
            Reporter:
            Woonsan Ko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development