Module: AtlasRb::System

Extended by:
FaradayHelper
Defined in:
lib/atlas_rb/system.rb,
lib/atlas_rb/system/user.rb

Overview

System-context callers — calls that authenticate as the seeded Atlas :system fixture rather than as a real user. The only client of this namespace today is the SSO callback in Cerberus, which provisions / refreshes the User row for a freshly-signed-in person.

Why a separate namespace

The :system principal needs a different bearer token (carried in Rails.application.credentials.atlas_system_token, not the user-side relay-signing / ATLAS_JWT credentials) and pairs with a hard-pinned User: header (always NUID, never the acting user). Atlas's require_auth enforces the pairing — the system token paired with a real-user NUID is a 401.

Routing system calls through their own class makes the carve-out structural: there is no kwarg that flips a regular call into a system call. The class itself is the marker.

Defined Under Namespace

Classes: User

Constant Summary collapse

NUID =

The NUID of Atlas's seeded :system fixture. Atlas's find_by_role(:system) returns the row with this NUID; pairing validation in require_auth is role-based, but the seed convention is stable and is the value carried in the User: header on every FaradayHelper#system_connection request.

"000000000"

Constants included from FaradayHelper

FaradayHelper::ASSERTION_AUDIENCE, FaradayHelper::ASSERTION_ISSUER, FaradayHelper::ASSERTION_TTL

Class Method Summary collapse

Methods included from FaradayHelper

connection, multipart, system_connection, with_file_part

Class Method Details

.reindex(id) ⇒ Faraday::Response

Re-project a single resource's Solr doc from Atlas's current Postgres/OCFL state. Solr-only on the server — no lifecycle transition, no audit event, no optimistic-lock bump. The purpose-built lever for refreshing a stale projection after an indexer ships or changes (e.g. the catalog's classification_ssim "Content" facet), without abusing AtlasRb::Work.complete to nudge Solr as a finalize side effect.

Idempotent. Authenticates as the Atlas :system fixture via FaradayHelper#system_connection, so there is no way to issue it as a regular user.

Examples:

Refresh one drifted Work after a new indexer shipped

AtlasRb::System.reindex("neu:abc123")

Parameters:

  • id (String)

    the NOID of any resource (Work, Collection, Community, FileSet, ...).

Returns:

  • (Faraday::Response)

    the raw response. Status 204 on success; 404 if the id does not resolve.



32
33
34
# File 'lib/atlas_rb/system.rb', line 32

def self.reindex(id)
  system_connection.post("/resources/#{id}/reindex")
end

.reindex_subtree(id) ⇒ Integer

Re-project a resource AND its full descendant subtree — descendant containers (Collection/Community) plus the Works beneath them, a superset of Atlas's re-parent cascade so Work-level projections refresh too. Same Solr-only, side-effect-free semantics as reindex.

Synchronous on the server: rooted at a Collection it refreshes that Collection's contents; rooted at the top Community it backfills the whole repository. For a pathologically large subtree, root lower or drive the cascade in chunks (repeated calls) rather than relying on Atlas to grow a job runner — bulk orchestration lives in the consumer.

Examples:

Backfill a Collection's contents after an indexer change

AtlasRb::System.reindex_subtree("neu:collection1")  # => 42

Parameters:

  • id (String)

    the NOID of the subtree root.

Returns:

  • (Integer)

    the number of resources re-projected (the server's reindexed count).



53
54
55
56
# File 'lib/atlas_rb/system.rb', line 53

def self.reindex_subtree(id)
  response = system_connection.post("/resources/#{id}/reindex_subtree")
  JSON.parse(response.body)["reindexed"]
end