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
Issues Found1. return new ResponseEntitySearchAndReplaceResultView(
SearchAndReplaceResultView.builder()
.success(!hasErrors)
.hasErrors(hasErrors)
.build());These two fields always carry the same information ( 2.
Consider logging the partial count before throwing, or surfacing it in the error response. 3. No upper-bound guard on Any valid ISO date including far-future dates (e.g., 4. if(!UtilMethods.isSet(textToSearchFor)){
Logger.info(MaintenanceUtil.class, "Returning because text to search for is null or empty");
// ← NO RETURN STATEMENT
}
if(textToReplaceWith == null){
Logger.info(MaintenanceUtil.class, "Returning because text to replace is null");
// ← NO RETURN STATEMENT
}This is a pre-existing bug (not introduced by this PR), but it's worth noting because the new REST layer is the only safety net. If 5. Every existing endpoint in this class has 6.
7. Missing test for
Summary: The main design concern is #1 (redundant/misleading |
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.
…tenance-search-replace-old-versions-pushed-assets
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