-
Bug
-
Resolution: Fixed
-
Neutral
-
3.0.3
-
-
Empty show more show less
-
Yes
-
UI FW 34, UI FW 35
-
3
If an asset is missing its mime type then this will cause an unhandled exception to occur when linking to the asset. It's unclear how someone might end up with this missing metadata but I am reporting the issue in the case we get some more clarity later. See AssetPreviewProvider.java#73.
Reproduce
- Export an asset from the dam. Say /tours/shark_brian_warrick_0824.JPG
- Delete the asset from the dam.
- In the export file remove the mime type property. See dam.tours.shark_brian_warrick_0824..JPG.xml
- Import the modified xml.
- Try to link to the asset using the MTK Text & Image component.
Expected
We should check for a missing mime type and provide an option for fixing the problem. Use the extension to look up the mime type in the server configuration.
Actual
Whole chooser grid is broken.
magnolia-error.log
ERROR info.magnolia.admincentral.AdmincentralErrorHandler 14.10.2020 23:56:00 -- AdmincentralUI has encountered an unhandled exception. java.lang.IllegalArgumentException: Could not parse '' at com.google.common.net.MediaType.parse(MediaType.java:1013) ~[guava-28.2-jre.jar:?] at info.magnolia.dam.app.imageprovider.AssetPreviewProvider.lambda$getResource$0(AssetPreviewProvider.java:73) ~[magnolia-dam-app-3.0.3.jar:?]
Workaround
Fix the mime type with a script
import info.magnolia.jcr.util.NodeUtil import org.apache.jackrabbit.commons.predicate.NodeTypePredicate import javax.jcr.PropertyType session = ctx.getJCRSession("dam") children = (NodeUtil.collectAllChildren(session.rootNode, new NodeTypePredicate("mgnl:asset", true))).iterator() mimeMappings = ctx.getJCRSession("config").getRootNode().getNode("server").getNode("MIMEMapping") while (children.hasNext()) { child = children.next() if (child.hasNode("jcr:content")) { contentNode = child.getNode("jcr:content") if (!contentNode.hasProperty("jcr:mimeType")) { println "Repairing jcr:mimeType property @ " + contentNode.path extensionProperty = contentNode.getProperty("extension") mimeType = (mimeMappings.getNode(extensionProperty.getValue().getString().toLowerCase())).getProperty("mime-type").getString() contentNode.setProperty("jcr:mimeType", mimeType) session.save() } } }
Notes
If the mime type is missing try and look it up using the extension.
We also need a special case for folders. MGNLDAM-900
- is related to
-
MGNLDAM-886 Dam Choose Dialog - Crash if Asset is Marked for Deletion
- Closed
-
MGNLDAM-900 damLinkField does not allow to select folders
- Closed
-
MAGNOLIA-6576 MIMEMapping needs rewrite
- Open
-
MGNLDAM-912 Improve support for custom asset metadata
- Open