Common Refactoring Patterns

Common Refactoring Patterns

Overview

This page documents common refactoring patterns applied to all 5 modules during migration from Okapi to Eureka:

  • mod-entities-links

  • mod-kb-ebsco-java

  • mod-notes

  • mod-quick-marc

  • mod-search

Special Case: mod-kb-ebsco-java has additional unique changes (see there).

1. Granular Capabilities Update

Why This Changed?

Replaced wildcard *.all permissions with granular capabilities. This change was necessary because *.all was not consistently working (on Eureka).

Before & After Comparison

// BEFORE (Okapi - mod-notes example) * table userPermissions | name | | 'notes.all' | | 'configuration.entries.collection.get' | | 'configuration.entries.item.post' | | 'configuration.entries.item.delete' | // AFTER (Eureka - mod-notes example) * table userPermissions | name | | 'configuration.entries.collection.get' | | 'configuration.entries.item.delete' | | 'configuration.entries.item.post' | | 'note.links.collection.get' | | 'note.links.collection.put' | | 'note.types.collection.get' | | 'note.types.item.delete' | | 'note.types.item.get' | | 'note.types.item.post' | | 'note.types.item.put' | | 'notes.collection.get' | | 'notes.item.get' | | 'notes.item.post' | | 'notes.item.put' |

2. x-okapi-tenant Header Enforcement

Critical Change

All requests MUST now include the tenant header for proper Eureka routing.

// BEFORE (Missing tenant header) * def headersUser = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitokenUser)', 'Accept': 'application/json' } // AFTER (With tenant header) * def headersUser = { 'Content-Type': 'application/json', 'x-okapi-token': '#(okapitoken)', 'x-okapi-tenant': '#(testTenant)', 'Accept': '*/*' }

Validation Checklist

  • Confirm all wildcard *.all permissions removed

  • Verify x-okapi-tenant exists in 100% of requests

Related content