Skip to content

Add startup task to put Tags (Angular) portlet in menu and remove Tags Legacy #34682

@hmoreras

Description

@hmoreras

Description

Implement a runonce startup task that ensures 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 the current PR so it can be delivered in a separate 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()).

Acceptance Criteria

  • New runonce task class in dotCMS/src/main/java/com/dotmarketing/startup/runonce/ (e.g. Task260211AddTagsNewPortletToMenu or follow current naming).
  • forceRun() returns true when: legacy portlet is in any layout, or Angular tags portlet 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 (or fallback) if missing, then clears layout cache.
  • Uses PortletID.TAGS and PortletID.TAGS_LEGACY from com.dotmarketing.util.PortletID.
  • Exception handling: in forceRun(), catch Exception (not DotDataException) because DotConnect.getInt() throws DotRuntimeException via getResult().
  • Logging via Logger; no System.out. Follow patterns from existing runonce tasks in the same package.

Priority

Medium

Additional Context

  • Reference implementation: Same package contains Task260206AddUsagePortletToMenu.java, which adds the Usage portlet to the menu with similar logic (get layout, insert into cms_layouts_portlets, clear cache). Use it as a pattern; note that task uses getInt("count") in forceRun() and therefore should catch Exception (see compilation fix that was applied before removal).
  • Tables: cms_layout, cms_layouts_portlets. Columns used: layout_id, portlet_id, portlet_order, id (UUID for new rows).
  • Layout lookup: Prefer layout with LOWER(layout_name) = 'content types'; fallback: any layout that has tags-legacy (use its layout_id).
  • Insert: INSERT INTO cms_layouts_portlets(id, layout_id, portlet_id, portlet_order) VALUES (?, ?, ?, ?) with UUIDUtil.uuid() for id and max(portlet_order)+1 for the chosen layout.
  • This work was split out from the PR that adds the Tags Angular portlet to the menu (issue-32937) so the startup task can be reviewed and merged in a dedicated PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions