Skip to content

Add startup tasks to put Tags and Plugins (Angular) portlets in menu #34682

@hmoreras

Description

@hmoreras

Description

Implement two runonce startup tasks that wire up Angular portlets into the admin menu as part of the migration away from legacy JSP portlets.


Task 1 — Tags portlet menu migration

Ensure the Angular Tags portlet (id tags, route /tags) is present in the admin menu and the legacy Tags portlet (tags-legacy) is removed from all layouts. This was previously implemented in `Task260211AddTagsNewPortletToMenu` and removed from its original PR so it can be delivered in a dedicated PR.

The task should:

  • Run when: Any layout still has `tags-legacy`, or no layout has `tags`, or any layout has the old id `tags-new`.
  • On run:
    1. Migrate layout entries from portlet id `tags-new` to `tags` (portlet was renamed).
    2. Remove `tags-legacy` from all layouts (so it does not appear in the sidebar).
    3. If `tags` is still not in any layout after migration, add it to the "Content Types" layout (or fallback to a layout that contained `tags-legacy`).
    4. Clear layout cache (CacheLocator.getLayoutCache().clearCache()).

Task 2 — Plugins portlet menu addition

Ensure the Angular Plugins portlet (id plugins, route /plugins) appears in the admin menu right after the existing legacy dynamic-plugins JSP portlet (OSGI Manager). Both portlets live in the same menu group.

The task should:

  • Run when: The plugins portlet is not present in any layout.
  • On run:
    1. Find the layout containing dynamic-plugins.
    2. Shift all portlets in that layout with portlet_orderdynamic-plugins.portlet_order + 1 up by 1 to make room.
    3. Insert plugins with portlet_order = dynamic-plugins.portlet_order + 1.
    4. Clear layout cache (CacheLocator.getLayoutCache().clearCache()).

Acceptance Criteria

Tags task

  • New runonce task class in dotCMS/src/main/java/com/dotmarketing/startup/runonce/ (e.g. Task260211AddTagsNewPortletToMenu, following current date-based naming).
  • forceRun() returns true when: tags-legacy is in any layout, or tags is in zero layouts, or tags-new is in any layout.
  • executeUpgrade() migrates tags-newtags, removes tags-legacy from all layouts, adds tags to "Content Types" layout (or fallback) if missing, then clears layout cache.
  • Uses PortletID.TAGS and PortletID.TAGS_LEGACY from com.dotmarketing.util.PortletID.
  • Exception handling: forceRun() catches Exception (not just DotDataException) because DotConnect.getInt() can throw DotRuntimeException.
  • Registered in TaskLocatorUtil.getStartupRunOnceTaskClasses().

Plugins task

  • New runonce task class (e.g. Task260318AddPluginsPortletToMenu, following current date-based naming).
  • forceRun() returns true when plugins portlet is absent from all layouts (COUNT = 0); catches Exception.
  • executeUpgrade() finds the layout containing dynamic-plugins, shifts subsequent portlets' portlet_order up by 1, inserts plugins immediately after dynamic-plugins, then clears layout cache.
  • If dynamic-plugins is not found in any layout, logs an error and exits gracefully without inserting.
  • Uses PortletID.DYNAMIC_PLUGINS and PortletID.PLUGINS from com.dotmarketing.util.PortletID.
    • Note: PLUGINS enum entry must be added to PortletID.java (resolves to "plugins" by default naming convention).
  • Registered in TaskLocatorUtil.getStartupRunOnceTaskClasses().

Both tasks

  • Logging via Logger; no System.out.
  • Idempotent: running more than once does not duplicate entries or corrupt layout order.
  • Follow patterns from existing tasks in the same package (see Task260206AddUsagePortletToMenu.java as reference).

Priority

Medium


Additional Context

Already done in the companion PR (issue-34732):

  • portlet.xmlplugins portlet entry added with PortletController class (Angular).
  • PortletID.javaPLUGINS enum entry added.
  • app.routes.ts/plugins route now has canActivate: [MenuGuardService].
  • portlet.xml already has tags and tags-legacy entries.

Startup task reference: Task260206AddUsagePortletToMenu.java — same pattern for layout lookup, cms_layouts_portlets insert, and cache clear.

Tables: cms_layout, cms_layouts_portlets. Columns: layout_id, portlet_id, portlet_order, id (UUID for new rows).

Insert pattern:

INSERT INTO cms_layouts_portlets(id, layout_id, portlet_id, portlet_order) VALUES (?, ?, ?, ?)

Use UUIDUtil.uuid() for id.

Shift pattern (for Plugins task):

UPDATE cms_layouts_portlets SET portlet_order = portlet_order + 1
WHERE layout_id = ? AND portlet_order >= ?

This work was split out from the PR that adds the Angular portlets (issue-34732) so startup tasks can be reviewed and merged in a dedicated PR.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions