feat(content-drive): add FILEASSET base-type → content-type resolution strategy (#36279)#36317
feat(content-drive): add FILEASSET base-type → content-type resolution strategy (#36279)#36317zJaaal wants to merge 7 commits into
Conversation
#36279) Content Drive's upload dialog lets users pick Asset vs File, which are semantically base types. Previously only DOTASSET could be resolved from a base type on the backend, so firing the NEW workflow action with baseType: FILEASSET failed with "content type or base type is not set or is invalid". This adds the missing FILEASSET resolution and switches the frontend to send the base type. Backend: - Extract the dotAsset mime-matching algorithm into a reusable BaseTypeMimeTypeMatcher (parameterized by base type + binary field var); DotAssetAPIImpl.tryMatch now delegates to it (DOTASSET behavior unchanged). - Move DotAssetBaseTypeToContentTypeStrategyImpl out of the resolver into its own class and add FileAssetBaseTypeToContentTypeStrategyImpl, which mime-matches FILEASSET content types and falls back to the default FileAsset. - Register both strategies; fix BaseTypeToContentTypeStrategyResolver.subscribe which ignored its baseContentType arg and always registered under DOTASSET. Frontend: - Revert uploadDotAsset to its original 2-arg form; add uploadFileByBaseType (DotUploadFileService) and newContentletByBaseType (DotWorkflowActionsFireService) which send baseType instead of contentType. - Content Drive now emits DOTASSET/FILEASSET and routes uploads through the new method; root-level uploads carry the current site identifier so they land on the browsed site, not the default host. Tests: resolver unit test (subscribe regression + FILEASSET registration), FileAsset strategy integration test, and frontend specs for the new methods, base-type selection, and current-site root upload. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Claude finished @zJaaal's task in 2m 2s —— View job Rollback Safety Analysis
Result: ✅ Safe To RollbackAll 18 changed files were checked against every rollback-unsafe category. None matched.
Summary: This PR is purely additive — new Java strategy classes ( |
🤖 Bedrock Review —
|
|
Thanks for the automated review. I went through each finding against the actual code — the Critical/High items are false positives. Details below. 🔴 Critical — 🔴 Critical — 🟠 High / 🟡 Medium (×2) — 🟠 High — 🟡 Medium — Net: no code changes needed for the Critical/High findings. Will address the logging nit if reviewers want it. — Posted by Claude on behalf of @zJaaal |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🤖 Bedrock Review —
|
🤖 Bedrock Review —
|
🤖 Bedrock Review —
|
fabrizzio-dotCMS
left a comment
There was a problem hiding this comment.
it looks good however I think the inner logic of the matcher could be more semantic making it a lot easrier to read/understand
🤖 Bedrock Review —
|
…avadocs Address review feedback on the matcher's readability: replace the magic-index Map[6] array with a MimeTypeBuckets class whose named fields (exact/partial/ wildcard x current-site/system-host) make the resolution precedence explicit. Behavior is unchanged (same precedence order). Also add javadoc to the matcher's private methods and to the FileAsset strategy's apply()/getBinary(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🤖 Bedrock Review —
|
🤖 Bedrock Review —
|
Proposed Changes
Resolves #36279.
Content Drive's upload dialog (PR #36243 / #35575) lets users choose Asset vs File — semantically these are base types. But the backend could only resolve a content type from a base type for
DOTASSET, so firing theNEWworkflow action withbaseType: FILEASSET(nocontentType) failed with "The content type or base type, is not set or is invalid." This adds the missingFILEASSETresolution strategy and switches the Content Drive frontend to send the base type for both options.Backend
BaseTypeMimeTypeMatcher(new) — the dotAsset mime-matching algorithm extracted into a reusable matcher parameterized by base type + binary field var.DotAssetAPIImpl.tryMatchnow delegates to it, so DOTASSET behavior is unchanged.DotAssetBaseTypeToContentTypeStrategyImpl— moved out ofBaseTypeToContentTypeStrategyResolverinto its own top-level class (per review feedback).FileAssetBaseTypeToContentTypeStrategyImpl(new) — mirrors dotAsset: matches the uploaded file's mime type against theaccept(ALLOWED_FILE_TYPES) field variable of theFILEASSETcontent types, falling back to the system defaultFileAsset.BaseTypeToContentTypeStrategyResolver— registers both strategies and fixes a latent bug insubscribe(...), which ignored itsbaseContentTypeargument and always registered underDOTASSET(it also threwMultiple entries with same keyon any second registration).MapToContentletPopulator.getContentTypeInodeis intentionally left untouched (resolution happens earlier inContentHelper.tryToSetContentType).Frontend
uploadDotAssetto its original 2-arg form (existing callers — browser selector, edit-content — unchanged).newContentletByBaseType(DotWorkflowActionsFireService) anduploadFileByBaseType(DotUploadFileService), which sendbaseTypeinstead ofcontentType.DOTASSET/FILEASSETand routes uploads through the new method.Screen.Recording.2026-06-25.at.2.01.55.PM-1.mov
Checklist
data-access(694) andportlets-content-drive(667) suites + lint pass.Testing
./mvnw verify -pl :dotcms-integration -Dcoreit.test.skip=false -Dit.test=FileAssetBaseTypeToContentTypeStrategyImplTest🤖 Generated with Claude Code