Details

    • Type: Technical Documentation
    • Status: Closed
    • Priority: Minor
    • Resolution: Completed
    • Affects Version/s: 7.4.X, Master
    • Fix Version/s: None
    • Labels:
      None
    • Sprint:
      Iteration 45, Iteration 46, Iteration 47, Iteration 48, Iteration 49, Iteration 50, AppSec Iteration 51, AppSec Iteration 52, AppSec Iteration 53, AppSec Iteration 54, AppSec Iteration 55, AppSec Iteration 56
    • Type of Documentation:
      Developer

      Description

      Background

      Why does this feature exist?

      Because we have different URL Matching procedures/logics across portal, and their complexity is linear with the number of patterns to match and the length of the patterns. This library implements servlet spec URL Matching procedures and is constant with regards to the number of patterns and only depends on the length of the longest pattern to match.

      Who needed it?

      Portal/developers

      What problem does it solve?

      It solves the problem listed in why does this feature exist?, by unifying URL Matching procedures to those of servlet spec, and being performant.

      How can it be used by the developer?

      Developers for portal can use this URL Pattern Mapper library to store URL Patterns and then matching URLs. See example in PortalCORSServletFilter.java.

      How does it make life easier?

      Developers don't have to implement their URL Matching logic and they can be certain the library is correct and performs nicely.

      Features

      What does this feature do? For example, does it let you add/change/delete anything?

      It allows developers to match URLs. Nothing is changed in terms of stored data.

      How else does it operate on data?

      Typically the URL Pattern Mapper consumes a pre-defined URL Patterns (created by developers or set by admins), and builds a struct of URLPatternMapper, then it will return you the matched data that paired with the pattern for your input URLs.

      Can a developer modify or customize any of these features?

      It is not expected for developers to extend this library.

      Why would anybody want to use or develop on this?

       Well, no one wants to maintain multiple sets of code that does similar things, and everyone loves running fast.

      Steps

      List the steps a developer needs to take to implement this feature, or a user needs to perform in order to use this feature.

      For developers to use this library
      They need to import the module in build.gradle as compileOnly project(":core:petra:petra-url-pattern-mapper"),
      then they need to make Mapping from the URL Pattern to whatever data he wants to pair up.
      Calling URLPatternMapperFactory.create() with the mapping will create the instance of URLPatternMapper for you.
      With previous steps completed, you can now find the matched URL Pattern(s) with any given URL by calling URLPatternMapper.getValue(String), or URLPatternMapper.getValues(String). If performance is important to your usage then you can even use URLPatternMapper.consumeValues() to avoid creating an intermediate list.

      Code

      Provide example code illustrating an example of this feature. Explain what the code does and how it works.

      Interface URLPatternMapper, this interface defines what a developer retrieve from an URLPatternMapper.
      Factory URLPatternMapperFactory, this class will instantiate either DynamicSizeTrieURLPatternMapper or a StaticSizeTrieURLPatternMapper based on the number of patterns need to be stored.
      Concrete implemetation, DynamicSizeTrieURLPatternMapper this implementation has an underlying data structure of Trie/prefix tree.
      Concrete implemetation, StaticSizeTrieURLPatternMapper this implementation also has an underlying data structure of Trie/prefix tree, but we store the index of patterns to a long primitive so that this implementation runs even faster, at a cost of limited number(64) of patterns can be stored.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              arthur.chen Arthur Chen
              Reporter:
              nora.szel Nóra Szél
              Recent user:
              Nóra Szél
              Participants of an Issue:
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Packages

                  Version Package