Skip to content

feat(dotcdn): migrate dotCDN from OSGI plugin to core#35588

Open
swicken wants to merge 10 commits into
mainfrom
feat/dotcdn-core-migration
Open

feat(dotcdn): migrate dotCDN from OSGI plugin to core#35588
swicken wants to merge 10 commits into
mainfrom
feat/dotcdn-core-migration

Conversation

@swicken
Copy link
Copy Markdown
Member

@swicken swicken commented May 6, 2026

Summary

Migrates the dotCDN plugin from a standalone OSGI plugin into the dotCMS core application, providing first-class CDN cache purging and analytics as a built-in capability.

Backend (com.dotcms.cdn)

  • DotCDNAPI / DotCDNAPIImpl — Bunny integration for cache invalidation and analytics (bandwidth, requests, threats, cached vs uncached stats)
  • DotCDNResource — REST endpoints for stats retrieval and on-demand cache invalidation
  • CDNInterceptor — Web interceptor that records debug headers when enabled
  • DotCDNInvalidateActionlet — Workflow actionlet to purge CDN cache on content publish
  • PushPublishOnReceiverEndSubscriber — Automatically invalidates CDN cache after push-publish receive events, with isolated failure handling per receiver
  • DotCDNTool — Velocity ViewTool for CDN domain lookup in templates
  • dotCDN.yml — App descriptor for Bunny credentials (domain, zone ID, API key)
  • Registration in DotRestApplication, InterceptorFilter, toolbox.xml, portlet.xml, and LocalSystemEventSubscribersInitializer

Frontend (@dotcms/portlets/dot-cdn)

  • DotCdnComponent — Main portlet with Chart.js-based bandwidth/request/threat visualizations
  • DotCdnFiltersComponent — Date range controls and metric type selectors
  • DotCdnStore — Signal-based ComponentStore managing stats fetching, date ranges, and chart data
  • DotCdnService — HTTP service for stats and invalidation REST calls
  • Lazy-loaded route registered in app.routes.ts

Safety & resilience

  • Guards against missing CDN config in global subscribers and the workflow actionlet — logs warnings instead of throwing
  • Rejects plugin REST resources when a core resource already exists at the same path, preventing shadowing
  • Isolates receiver purge failures so one failed receiver doesn't block others

Tests

  • DotCDNAPITest — Unit tests covering stats aggregation, cache invalidation, error handling, and missing-config scenarios

Test plan

  • Verify dotCDN portlet renders with charts when Bunny credentials are configured via Apps
  • Verify cache invalidation via the portlet UI and via the workflow actionlet
  • Verify push-publish receiver triggers CDN purge on the receiving server
  • Verify graceful degradation when CDN app is not configured (no crashes, warning logs)
  • Verify DotCDNAPITest unit tests pass
  • Verify the OSGI plugin version is no longer needed (no conflicts at the REST path level)

🤖 Generated with Claude Code

Closes #35593

swicken added 7 commits May 5, 2026 21:19
WIP checkpoint — no real testing has been done yet. This is a
structural migration before improving the UI (date range controls,
chart formatting, hourly granularity).

Backend migration:
- Moved all Java classes from com.dotcms.cloud.* to com.dotcms.cdn.*
- Registered REST resource, workflow actionlet, ViewTool, event
  subscriber, web interceptor, and portlet in core
- Added app descriptor YAML (auto-discovered by AppsAPI)
- Dropped OSGI Activator, AppUtil, and unused BCDNStorage client
- Includes #35320 fixes: empty response handling, Integer→Double cast

Frontend migration:
- Moved Angular app from apps/dotcdn/ to libs/portlets/dot-cdn/
- Converted to standalone component (no NgModule)
- Updated PrimeNG tabs to new p-tablist/p-tabpanel API
- Registered as lazy-loaded Angular portlet route (no JSP/iframe)
- Added smart bandwidth unit selection (B/KB/MB/GB)
- Added human-readable number formatting for requests
- Fixed duplicate y-axis on charts
- Temporary mock data options for visual testing (to be removed)

Unit tests: 7/7 passing (DotCDNAPITest)
- Added origin response time, cache hit rate chart, and error rate
  (4xx/5xx) charts from Bunny API (loadErrors + loadOriginResponseTimes)
- Replaced dropdown with segmented button bar (Today|24h|7d|30d|90d|Custom)
  plus inline date range picker for custom selection
- Backend passes hourly=true to Bunny for short ranges (<=2 days)
- 2x2 chart grid layout with stat cards (4 metrics)
- Smart date labels: hourly ("Apr 1 2pm") vs daily ("Apr 1")
- Integer-only ticks on request/error charts
- Cache hit rate chart with 0-100% scale
- Toolbar with filters scoped to Overview tab only
- Null-safe handling for origin response time
… same path

Prevents the Jersey FATAL ambiguous resource error that crashes the
entire REST layer when the dotCDN OSGI plugin is still installed
alongside the core migration. DotRestApplication.addClass() now checks
the plugin's @path against CORE_REST_PATHS and logs a warning instead
of registering the conflicting resource.
…nd actionlet

DotCDNAPIImpl constructor throws when App secrets are absent, which breaks
globally-registered code (push-publish subscriber, workflow actionlet) on
sites without dotCDN configured. Add DotCDNAPI.isConfigured() check and
skip gracefully. Also fix NPE in createUrlsToPurgeForContentlet when
identifier lookup returns null, and downgrade per-URL purge logging from
INFO to debug.
@github-actions

This comment was marked as resolved.

@claude

This comment was marked as outdated.

@github-actions github-actions Bot added Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code labels May 6, 2026
Fix UTC date handling, add defensive stats parsing, close Response
in invalidateAll, add isConfigured guard to REST endpoints, log
async purge failures, isolate per-contentlet purge in subscriber,
restrict purge URLs to relative paths, surface API errors in the
frontend store, and fix Math.max stack overflow risk. Run nx
format:write on all CDN frontend files to pass CI format check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Migrate dotCDN from OSGI plugin to core

1 participant