Current implementation of the Catalog UI does not embed the
filters parameter in the URL. We avoided that because the URL gets (insanely) long and wanted to keep the URLs short.
We would like to use short URLs that embed the
filter settings and can be shared with others. This requires massaging the
filter JSON and storing it in a database and providing a unique short name for every (valid) filter used by the client.
- Add a new Entity called
- It serializes the provided
Filtersobject to a "normalized" JSON filter
- It stores this unique filter in as a
ShortFilterand can reuse an existing
shortNamewhen filter matches an existing record
- The filters
shortNameand the original filter JSON are embedded in response JSON every time filtered data is sent back to the client
- The client can use either the
shortNameor the full JSON filter to request data.
shortName must be unique in the database. The
jsonFilters must be unique in the database.
Converting a Filter to
- Normalize the filter
- Check if the normalized filter has a
- or Generate a new
ShortFilterfor a new filter
Normalizing the filter
- Remove any invalid filter values (blanks, etc.) from JSON
- Sort JSON keys alphabetically
- Convert JSON keys to lowercase
- Sort filter values alphabetically
"v1" + UUID.randomUUID().replaceAll("-", "")to generate the 1st version of the short name