maintenance portlet | Implement search/replace, drop old versions, and delete pushed assets APIs #35191#35231
Conversation
|
Claude finished @hassandotcms's task in 2m 18s —— View job PR Review
Issues1. The guard clauses log if(!UtilMethods.isSet(textToSearchFor)){
Logger.info(MaintenanceUtil.class, "Returning because text to search for is null or empty");
// ← no return here
}
if(textToReplaceWith == null){
Logger.info(MaintenanceUtil.class, "Returning because text to replace is null");
// ← no return here
}
// ... proceeds to run 50+ UPDATE statementsThe form validation ( 2.
3. HTTP 200 with When some DB tables fail the search/replace, the response is 4.
5.
Both are client errors, but they serialize differently. If the REST exception mapper treats them the same way this is harmless, but it's worth verifying — or aligning both to the same exception type. Fix this → 6. Minor: The Clean areas
|
b797ebe to
65d3572
Compare
…s, and delete pushed assets #35191 Add three new endpoints to MaintenanceResource: - POST /_searchAndReplace: database-wide find/replace across content tables - DELETE /_oldVersions: drop versionable objects older than a given date - DELETE /_pushedAssets: clear all push publishing history Includes Validated forms, @Value.Immutable response views, full Swagger annotations, and SecurityLogger entries for all destructive operations.
…ions, and pushed assets #35191 Tests cover: - _searchAndReplace: admin success, non-admin rejection, null/empty form validation, empty replaceString allowed - _oldVersions: admin success, non-admin rejection, missing date, invalid date formats - _pushedAssets: admin success, non-admin rejection
…ndant checkValid, log searchString #35199
…tring from SecurityLogger #35199
…ilure in searchAndReplace #35199
9c70839 to
fb599c9
Compare
|
|
||
| if (deleted < 0) { | ||
| throw new DotRuntimeException( | ||
| "Failed to delete old asset versions — check server logs for details"); |
There was a problem hiding this comment.
Let's include the value of dateStr in the message.
Summary
Add 3 new REST endpoints to
MaintenanceResource, replacing legacy DWR/Struts maintenance tools with modern REST APIs for the Maintenance portlet Tools tab.New endpoints:
POST /api/v1/maintenance/_searchAndReplace— Database-wide find/replace across text content in contentlets, containers, templates, fields, and links. Only affects working/live versions. Flushes all caches after completion.DELETE /api/v1/maintenance/_oldVersions?date=yyyy-MM-dd— Deletes all versions of versionable objects (contentlets, containers, templates, links, workflow history) older than the specified date. Uses ISO date format instead of legacy MM/dd/yyyy.DELETE /api/v1/maintenance/_pushedAssets— Clears all push publishing history records, making all assets appear as "never pushed" to all endpoints.Implementation details:
SearchAndReplaceFormextendsValidatedwith@JsonCreator, validates searchString is non-empty, allows empty replaceString (delete occurrences)@Value.Immutableviews (SearchAndReplaceResultView,DropOldVersionsResultView) with full Swagger/OpenAPI annotationsSecurityLoggerentries on all destructive operationsassertBackendUser()pattern (requireAdmin + requiredPortlet MAINTENANCE)ResponseEntityStringViewreused for simple _pushedAssets responseTest plan
./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dit.test=MaintenanceResourceIntegrationTestPOST /_searchAndReplacewith valid search/replace strings returns{success: true, hasErrors: false}POST /_searchAndReplacewith empty searchString returns 400POST /_searchAndReplacewith empty replaceString succeeds (deletes occurrences)DELETE /_oldVersions?date=2000-01-01returns{deletedCount: N, success: true}DELETE /_oldVersions?date=01/01/2000returns 400 (wrong format)DELETE /_oldVersionswithout date param returns 400DELETE /_pushedAssetsreturns"success"Closes #35199, Closes #35201, Closes #35204