dotCMS / dotCMS/core

[TASK] Implement search and replace endpoint

Open
#35,199 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stale Team : Modernization
Dominant language
Java
Stars
970
Forks
486
Avg merge
3d 33m
Merged PRs (30d)
170

Description

Description

Implement POST /v1/maintenance/_searchAndReplace in MaintenanceResource.java. Performs a database-wide find/replace across text content in contentlet, container, template, field, and links tables. This is a dangerous, irreversible operation — only working/live versions are affected.

Acceptance Criteria
  • API caller must provide searchString (non-empty) and replaceString (non-null) in JSON body
  • Endpoint must call MaintenanceUtil.DBSearchAndReplace(searchString, replaceString)
  • Endpoint must flush all caches and reset permission references after replacement
  • API caller must receive a response indicating success or whether errors occurred during replacement
  • Must require CMS Administrator role and Maintenance portlet access
  • API caller must receive 400 Bad Request if searchString is empty
Priority

None

Additional Context
  • MaintenanceUtil.DBSearchAndReplace() uses parameterized SQL REPLACE() calls — no SQL injection risk
  • Tables affected: contentlet (text1-25, text_area1-25), containers (code, pre_loop, post_loop), template (body), field (field_values), links (url)
  • Only updates working/live versions via version_info joins
  • Struts legacy: ViewCMSMaintenanceAction.searchAndReplace() lines 404–440

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in MaintenanceResource.java and compare the legacy behavior in ViewCMSMaintenanceAction.searchAndReplace() at lines 404–440. Trace MaintenanceUtil.DBSearchAndReplace() and the existing maintenance security, cache, and permission handling. Done means the endpoint meets every listed validation, authorization, replacement, cache-reset, and response acceptance criterion.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.